将加密数据插入链接服务器的安全选项 - SQL Server 2014

Secure option for inserting encrypted data into linked server - SQL Server 2014

我在一台服务器上托管了一个数据库,该服务器与另一台存储自定义应用程序数据的服务器有链接服务器连接。具有链接服务器连接的数据库需要将来自 table 的敏感数据插入自定义应用程序链接服务器上托管的数据库中。

我按照本指南 (https://www.mssqltips.com/sqlservertip/2431/sql-server-column-level-encryption-example-using-symmetric-keys/) 在用于自定义应用程序的服务器上创建了对称密钥,我可以在自定义应用程序服务器上正常插入和读取加密数据。

正如您在上面的第 3 步中看到的,我在自定义应用程序服务器的数据库中创建了一个主密钥。我现在想做的是使用:

INSERT INTO LinkedServer.Table
SELECT EncryptByKey(Key_GUID('myKey'), someColumn), etc
FROM SensitiveData.Table

毕竟,我的问题是,由于此密钥仅存在于用于自定义应用程序的链接服务器上,因此当我尝试在从敏感数据服务器到自定义应用程序服务器的 INSERT 上使用 EncryptByKey 时出现错误消息:

Remote function reference 'LinkedServer.DatabaseName.dbo.EncryptByKey' is not allowed, and the column name 'LinkedServer' could not be found or is ambiguous.

我是否应该在敏感数据服务器上创建相同的密钥,以便它可以从那里加密,这样做是否存在安全风险?或者是否有某种语法方式告诉它使用链接服务器上的密钥进行加密?或者我想做的最后一种方法是在自定义应用程序服务器中创建另一个 table,插入来自敏感数据服务器的数据,因为它通常出现,在那个 table 上放置一个触发器并插入后,使用自定义应用服务器上的Master Key加密数据,移动到table我要保存的加密数据中,从新的table?

中删除

我就是这样解决这个问题的。

  1. I created a temp table in my linked server database to hold the plain text data.

  2. I set an AFTER INSERT trigger on the temp table to insert into the encrypted table using the MASTER KEY on the linked server to encrypt all the values.

  3. Deleted all data from the temp table.

这就完成了工作,我仍然不确定我是否正确处理了这种情况,所以请随时对此发表评论或添加答案 post。