RSA加密的Web配置在IIS Express中工作,但在本地IIS中不起作用

时间:2017-02-16 15:43:34

标签: asp.net iis visual-studio-2015 aspnet-regiis.exe web-config-encryption

我使用RSA容器密钥加密来加密web.config中的appSettings。在IIS Express中运行时,加密的Web配置在Visual Studio中可以正常工作。但是当我在项目属性中将其更改为本地IIS时(在VS 2015中),我收到错误

"Failed to decrypt using provider 'MyEncryptionProvider'. Error message from the provider: The RSA key container could not be opened.". 

如果Web配置已解密,则它可以在本地IIS和IIS Express中使用。

这些是我使用的命令:

aspnet_regiis.exe  -pc MyCustomKeys -exp
aspnet_regiis.exe  -pa MyCustomKeys "NT AUTHORITY\NETWORK SERVICE"
aspnet_regiis.exe  -pef appSettings "D:\Demo\Encrypting configuration" -prov MyEncryptionProvider

configProtectedData

 <configProtectedData>
<providers>
  <add keyContainerName="MyCustomKeys"
           useMachineContainer="true"
           name="MyEncryptionProvider"
           type="System.Configuration.RsaProtectedConfigurationProvider"/>
</providers>

0 个答案:

没有答案
相关问题