3

I have a permissions issue with regard to using a symmetric key under a specific user name when a stored procedure is executed.

Despite running

GRANT CONTROL ON CERTIFICATE::myCert TO myUser
GRANT VIEW DEFINITION ON SYMMETRIC KEY::myKey TO myUser

I still get the same error:

Cannot find the symmetric key 'myKey', because it does not exist or you do not have permission.

The Master Key, Certificate and Symmetric Key were set under the database the user name relates to.

If I run the SP under Windows Authentication it works fine.

Here's the stored procedure:

OPEN SYMMETRIC KEY myKey DECRYPTION
BY CERTIFICATE myCert

INSERT INTO sp_Password
(billEncryptPassword)
VALUES(ENCRYPTBYKEY(KEY_GUID('myKey'),@billEncryptPassword))

RETURN @@IDENTITY       
CLOSE SYMMETRIC KEY myKey 

What have I missed?

4

2 回答 2

0

之后您就失踪CLOSE MASTER KEY了,这会干扰您随后的加密/解密。

于 2012-07-31T22:33:07.517 回答
0

即使以系统管理员身份运行它,我也遇到了同样的问题。

为了解决这个问题,我目前正在关闭所有可以正常工作的打开键。我宁愿只关闭我打开的东西。

关闭所有对称键;

--- 附录

我刚刚尝试了 AES_256 与 DES 加密,而 AES_256 对我有用。

于 2011-07-26T14:53:49.970 回答