将始终加密的证书放置在 IIS 7.5 Web 服务器上的什么位置?

2024-02-22

我们有一个采用始终加密的 SQL Server 2016 数据库。我们最近发布的 ASP.net 网站尝试从该数据库中提取数据,当这样做时,我们收到此错误:

Error: Failed to decrypt column 'EnSSd'. Failed to decrypt a column encryption key using key store provider: 'MSSQL_CERTIFICATE_STORE'. The last 10 bytes of the encrypted column encryption key are: 'B8-48-B3-62-90-0B-1D-A6-7D-80'. Certificate with thumbprint '97B0D3A64CADBE86FE23559AEE2783317655FD0F' not found in certificate store 'My' in certificate location 'CurrentUser'. Verify the certificate path in the column master key definition in the database is correct, and the certificate has been imported correctly into the certificate location/store. Parameter name: masterKeyPath

现在我们知道这意味着证书尚未放置在服务器上的正确位置。在开发过程中,我们只是将证书放置在个人证书存储下的证书管理单元中,并且该方法有效,但是现在该网站已发布,我们尝试在 Web 服务器上执行相同的操作,但它不起作用(我们有点认为它是有效的)不会)。

站点启用匿名认证,匿名用户身份为IUSR。 ASP.NET 模拟已禁用。

证书放置在哪里合适?


更新 - 我们通过将应用程序池身份帐户更改为创建证书的帐户来使其工作。这也是将证书添加到 Web 服务器上的当前用户个人列表时使用的帐户。我们宁愿不使用这个帐户,那么同样,证书放置的正确位置在哪里?


始终加密要求访问数据库的用户同时拥有公钥和私钥,这似乎要求您使用该帐户来生成证书,因为他们将拥有此密钥。

我通常做的是生成证书并使用私钥和安全密码导出证书。然后将带有密钥的证书导入到您用于运行应用程序池的帐户的个人存储中。这不能是通用集成帐户,而必须是您指定的服务帐户。

以用户身份运行 powershell 脚本:

whoami
COMPUTER\myIISPoolUser
Set-Location -Path cert:\localMachine\my
Import-PfxCertificate –FilePath c:\AlwaysEncrypt.pfx

或使用MMC。

whoami
COMPUTER\myIISPoolUser
certmgr.msc

您还必须允许 APP Pool 用户加载用户配置文件 https://blogs.msdn.microsoft.com/vijaysk/2009/03/08/iis-7-tip-3-you-can-now-load-the-user-profile-of-the-application-pool-identity/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

将始终加密的证书放置在 IIS 7.5 Web 服务器上的什么位置? 的相关文章

随机推荐