我正在使用add an assembly尝试asymmetric key到SQL2008中的数据库。
我们使用十六进制字符串添加程序集(仅通过sql查询向程序集添加程序集)
USE [master]
GO
IF NOT EXISTS (SELECT * from sys.asymmetric_keys where name = 'ManagedAsymmetricKey')
BEGIN
CREATE ASYMMETRIC KEY ManagedAsymmetricKey FROM FILE = 'C:\Managed.dll'
CREATE LOGIN CLRLogin FROM ASYMMETRIC KEY ManagedAsymmetricKey
GRANT UNSAFE ASSEMBLY TO CLRLogin
END
GO
USE [$dbName]
GO
CREATE ASSEMBLY [Managed]
AUTHORIZATION [dbo]
FROM 0x4D5A....
WITH PERMISSION_SET = UNSAFE
GO
这将通过我们收到的网络在本地实例上运行;
The certificate, asymmetric key, or private key file does not exist or has invalid format.
我可能错误地假设我应该首先添加密钥,我是否应该添加程序集然后执行CREATE ASYMMETRIC KEY ManagedAsymmetricKey FROM ASSEMBLY [workingDB].[dbo].[Managed]
行?
答案 0 :(得分:5)
您可以使用以下步骤使其正常工作:
授予登录不安全程序集权限
CREATE ASSEMBLY [Managed]
AUTHORIZATION [dbo]
FROM 0x4D5A....
WITH PERMISSION_SET = SAFE
CREATE ASYMMETRIC KEY ManagedAsymmetricKey FROM ASSEMBLY [Managed]
DROP ASSEMBLY [Managed]
CREATE LOGIN CLRLogin FROM ASYMMETRIC KEY ManagedAsymmetricKey
GRANT UNSAFE ASSEMBLY TO CLRLogin
答案 1 :(得分:2)
FROM FILE =
总是从SQL Server的角度出发。您可以将证书复制到数据库服务器上的本地驱动器。