【发布时间】:2013-08-27 00:36:48
【问题描述】:
我已经加密了 webconfig 文件的两个部分,一个称为 connectionStrings,另一个是使用相同 Provider 的 userAccount。
在我的代码中,connectionString 部分被解密得很好,没有任何问题,但是当涉及到解密名为 userAccounts 的第二部分时,我得到了一个错误。
这是确切的错误消息:
使用提供程序“AqueductDevProvider”解密失败。来自提供程序的错误消息:无法打开 RSA 密钥容器。
您的帮助将不胜感激。
谢谢
这是网页配置文件中的代码
<configProtectedData>
<providers>
<add name="AqueductDevProvider"
type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
keyContainerName="AqueductDevKeys"
useMachineContainer="true" />
</providers>
</configProtectedData>
<connectionStrings configProtectionProvider="AqueductDevProvider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue></CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue></CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
<userAccounts configProtectionProvider="AqueductDevProvider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue></CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue></CipherValue>
</CipherData>
</EncryptedData>
</userAccounts>
这就是我尝试从 UserAccounts 部分访问信息的方式
System.Configuration.ConfigurationManager.AppSettings["AdminName"]; userAccounts 中有一个名为 AdminName 的密钥,该密钥已加密
【问题讨论】:
-
向我们展示代码并向我们展示您的尝试。目前你只能希望有人在同一个地方并且有相同的错误消息(你尝试加载密钥容器一次而不是两次 - 只是一个有根据的猜测?)
-
我已经在问题中添加了代码,我正在加载一次密钥容器,但我正在使用它解密两个部分 connectionStrings 和 userAccounts。当我尝试访问 userAccounts 部分时收到错误消息。我对 RSA 加密非常陌生。如果我能提供更多信息,请告诉我。
标签: c# asp.net encryption rsa rsacryptoserviceprovider