SQL 加密 - 非对称密钥 - 第二台服务器
我在我的一台 SQL 服务器上创建了一个非对称密钥 (2008)。我加密了一个密码字段,并且可以在我的开发服务器上很好地检索该密码。
当我需要将这些数据移动到生产服务器时,就会出现这个问题。
以下是创建的密钥的代码:
CREATE MASTER KEY ENCRYPTION BY PASSWORD='#########'
CREATE ASYMMETRIC KEY UserEncryptionKey
WITH ALGORITHM = RSA_2048
现在,当我在生产服务器上运行此代码时,它会很好地创建密钥。但是,当我运行存储过程来获取密码时,它返回 NULL。
SQL:
SELECT EncryptByAsymKey(AsymKey_ID('UserEncryptionKey'), Password )
FROM Users WHERE UserName = '######'
对于我需要做什么才能使加密字段在多个 SQL Server 上工作有什么想法吗?
如果我需要澄清一些事情,请告诉我。
谢谢
I created an asymmetric key on one of my SQL servers (2008). I encrypted a password field and I am able to retrieve that password just fine on my development server.
The issue comes into play where I need to move this data to a production server.
Here is the code for the key that was created:
CREATE MASTER KEY ENCRYPTION BY PASSWORD='#########'
CREATE ASYMMETRIC KEY UserEncryptionKey
WITH ALGORITHM = RSA_2048
Now, when I run this on the production server, it creates the key just fine. However, when I run my sproc to get the password, it returns NULL.
SQL:
SELECT EncryptByAsymKey(AsymKey_ID('UserEncryptionKey'), Password )
FROM Users WHERE UserName = '######'
Any thoughts on what I need to do to get the encrypted field to work on multiple SQL Servers?
Please let me know if I need to clarify something.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要将加密数据从一个数据库移动到另一个数据库。从技术上讲是可行的,确实如此,但您可能会在此过程中泄露密钥,因此我宁愿不告诉您如何做到这一点。
当站点之间交换数据时,通常的过程将密钥管理和部署与数据传输分开。数据在传输之前进行解密,并使用专用的数据传输加密方案(例如 TLS 和 SSL),从而消除了部署和共享实际加密密钥的问题。
顺便说一句,通常不会使用非对称密钥加密数据。它们对于数据操作来说太慢了。每个人所做的都是使用对称密钥加密数据,然后使用非对称密钥加密对称密钥。
Do not move encrypted data from a database to another. Technically is possible, true, but you will likely compromise the key in the process so I rather not tell you how to do it.
When data is exchanged between sites, the usual procedure separates the key management and deployment from data transfer. Data is decrypted before transfer and dedicate encryption schemes for data transfer are used, like TLS and SSL, that eliminate the problem of deploying and sharing the actual encryption keys.
Asa side note, normally one does no encrypt data with asymmetric keys. They are way too slow for data operations. What everybody does is they encrypt data with a symmetric key and then encrypt the symmetric key with an asymmetric key.