ConnectionString 未在 SSIS 集成项目中加密

ConnectionString not encrypted in SSIS integration project

我正在 VS 2019 中构建一个集成服务项目。

我已经为 OLE DB/SQL 服务器添加了项目连接管理器。

我已经使用项目参数配置了连接字符串。 (Project.params 个文件)。

然后我将项目参数更改为使用“配置”,以便根据活动配置应用不同的值。

在项目 属性 设置中,保护级别设置为“EncryptSensitiveWithUserKey”。

但是,如果我检查 .dtproj 文件,两个连接字符串(Dev 和“Azure”)都未加密存储。这是一个问题,因为我希望能够将 .dtproj 文件包含在存储库中。

我是不是做错了什么?如果这种方式不可能,我还能如何安全地“保存”项目中的两个连接字符串以用于不同的配置?

由于保护级别设置为EncryptSensitiveWithUserKey,您应该将项目参数配置为Sensitive。为此,请单击“解决方案资源管理器”中的 Project.params 文件

然后,将参数设置为敏感。参数值将立即被屏蔽,如下图所示:

此外,让我们检查解决方案目录中的 project.params 文件。

如果我们使用文本编辑器打开文件,我们可以检查参数值是否已加密。

更新

正如评论中提到的OP,将连接字符串参数设置为敏感导致以下异常:

The expression will not be evaluated because it contains sensitive parameter variable "$Project::ConnectionString". Verify that the expression is used properly and that it protects the sensitive information. ".

基于以下Microsoft Tech community article

This behavior is by design. The best practices approach to storing the connection information in SSIS is not to store the entire connection string inside of one variable but to separate out the individual pieces (username, password, server, etc.). This makes configuration easier within environment variables as well.

这意味着我们应该将 ConnectionString 配置为非敏感的,同时为我们想要的每个连接字符串部分添加一个单独的敏感参数。

有用的链接: