Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 为什么我可以加密web.config,但不能在同一个框中解密它?错误是参数不正确_Asp.net_Iis - Fatal编程技术网

Asp.net 为什么我可以加密web.config,但不能在同一个框中解密它?错误是参数不正确

Asp.net 为什么我可以加密web.config,但不能在同一个框中解密它?错误是参数不正确,asp.net,iis,Asp.net,Iis,我得到一个错误,我可以加密web.config文件,但不能解密它。例如,我在web.config中有明文连接字符串,并使用以下命令对其进行加密: C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pef "connectionStrings" c:\inetpub\wwwroot\App Microsoft (R) ASP.NET RegIIS version 4.0.30319.0 Adminis

我得到一个错误,我可以加密web.config文件,但不能解密它。例如,我在web.config中有明文连接字符串,并使用以下命令对其进行加密:

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pef "connectionStrings" c:\inetpub\wwwroot\App
Microsoft (R) ASP.NET RegIIS version 4.0.30319.0
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation.  All rights reserved.
Encrypting configuration section...
Succeeded!
当我立即尝试解密它时,会出现以下错误:

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pdf "connectionStrings" c:\inetpub\wwwroot\App
Microsoft (R) ASP.NET RegIIS version 4.0.30319.0
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation.  All rights reserved.
Decrypting configuration section...
Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The parameter is incorrect.
 (c:\inetpub\wwwroot\IdentityManager\web.config line 9)

The parameter is incorrect.

Failed!
我尝试删除并重新创建RSA密钥,但这也不起作用:

aspnet_regiis -pz "NetFrameworkConfigurationKey"

aspnet_regiis -pc "NetFrameworkConfigurationKey"
我不知道为什么我可以成功加密而不能解密。对我来说,RSA是对称的


我是机箱的本地管理员。

当.NET配置为使用OEAP时,这似乎是一个问题。我发现这篇文章也有类似的问题:


我更新了machine.config文件,重新启动,问题就消失了。

有两个想法,但不知道为什么它会以一种方式工作,而不是另一种方式:将目录加引号;以管理员身份打开cmd。您是否在同一台计算机上加密和解密?您是否更改了私钥或公钥?@wazz-我以管理员身份运行,另外请注意,这台机器从2012 R2升级到2019。@samwu-这是在同一台机器上完成的。起初我没有换钥匙。为了排除故障,我将密钥重新创建为state并对文件重新加密。它仍然无法解密。你能发布你的web.config文件吗?您是如何设置RsaProtectedConfigurationProvider的?