【问题标题】:How to use secure encryption of an existing column in SQL Server 2005如何在 SQL Server 2005 中使用现有列的安全加密
【发布时间】:2010-09-16 02:38:17
【问题描述】:

我想加密 SQL Server 2005 中的现有列,使用 UPDATE 语句,将旧内容移动到新的加密列中。

所以我有 2 个选择:对称和非对称。

我遇到的问题是,使用对称密钥,我必须将密码嵌入到 SP 中才能读取如下列:

-- Create key (at some earlier point)
create symmetric key sk_user_profile with algorithm = aes_192 encryption by password = 'P@ssword!!';

-- Now encrypt the contents
-- open the key so that we can use it
open symmetric key sk_user_profile decryption by password = 'P@ssword!!';

UPDATE users
SET password_enc = encryptbykey(key_guid('sk_user_profile'), password_plain, 1, user_id)

close symmetric key sk_user_profile

现在如果我想选择数据,我仍然需要重新打开密钥

open symmetric key sk_user_profile decryption by password = 'P@ssword!!';

这不是重点,因为我在存储过程中嵌入了纯文本密码。

一些问题

  1. 有什么办法可以解决这个问题 - 即使用此密码创建一个证书,然后改为引用该证书?
  2. 是否必须购买此证书(如 SSL),还是我可以自己创建?
  3. 此方法是否可跨故障转移集群数据库进行扩展,即加密不基于机器,仅基于提供的密码。因此故障转移仍然可以读取密码

感谢您的帮助

【问题讨论】:

  • 有证书加密。

标签: sql-server-2005 encryption-asymmetric encryption-symmetric


【解决方案1】:

基本上你需要做的是:

create certificate MyEncryptionCertificate with subject = 'MyCertificate'

create symmetric key MySymmetricKey with algorithm = aes_256 encryption by certificate MyEncryptionCertificate

然后:

open symmetric key MySymmetricKey decryption by certificate MyEncryptionCertificate

select encryptbykey(key_guid('MySymmetricKey'), 'tada')) EncryptedMessage

我希望这个博客能帮助你。

SQL SERVER – Introduction to SQL Server Encryption and Symmetric Key Encryption Tutorial with Script

还有这篇博文,专门处理故障转移环境中的证书。

Solution Using Certificates Authentication on Production Servers

【讨论】:

  • 皮纳尔戴夫!!我怎么没想到!我希望有一种方法可以从密码生成证书。但是,这是否适用于集群环境。所以 Web -> 故障转移集群 -> (DB1/DB2)
猜你喜欢
  • 2011-01-10
  • 2013-09-22
  • 2011-06-11
  • 2011-08-07
  • 1970-01-01
  • 2017-04-19
  • 1970-01-01
  • 1970-01-01
  • 2011-03-10
相关资源
最近更新 更多