【问题标题】:Web.config Encryption ErrorWeb.config 加密错误
【发布时间】:2010-01-05 17:13:21
【问题描述】:

加密有问题。我授予所有用户对 RSA 文件夹的完全权限。我做了

C:\>aspnet_regiis -pe "appSettings" -location "web.config" -prov "RsaProtectedCo
nfigurationProvider"
Encrypting configuration section...
An error occurred executing the configuration section handler for appSettings.

Failed to encrypt the section 'appSettings' using provider 'RsaProtectedConfigur
ationProvider'. Error message from the provider: Object already exists.

Failed!

然后我做了

C:\>aspnet_regiis -pa "NetFrameworkConfigurationKey" "administrator"
Adding ACL for access to the RSA Key container...
The RSA key container was not found.
Failed!

紧随其后

C:\>aspnet_regiis -pc "NetFrameworkConfigurationKey" -exp
Creating RSA Key container...
The RSA key container could not be opened.
Failed!

没有什么对我有用。

谁能帮忙?

谢谢

【问题讨论】:

    标签: asp.net encryption rsacryptoserviceprovider aspnet-regiis.exe


    【解决方案1】:

    我遇到了同样的问题:

    aspnet_regiis -pa "NetFrameworkConfigurationKey" "{Domain}{Username}"

    以上行返回“未找到 RSA 密钥容器。”

    要解决此问题,我必须以管理员身份运行命令提示符(打开开始 > 附件 > 然后右键单击命令提示符并选择以管理员身份运行...)。即使我的帐户是管理员帐户,我也必须这样做。

    【讨论】:

    • 以管理员身份运行命令提示符为我解决了这个问题。
    【解决方案2】:
    C:\>aspnet_regiis -pe "appSettings" -location "web.config"
           -prov "RsaProtectedConfigurationProvider"
    

    在此行中,您的位置不正确。当您使用-pd 时,开关位置基于 IIS 的应用程序路径,并且 web.config 被假定为加密点。

    例如,如果您在 IIS 中有一个名为“Website 1”的应用程序和另一个名为“Website 2”的应用程序,并且您希望对“Website 1”中的 web.config 进行加密,您可以使用以下行:

    C:\>aspnet_regiis -pe "appSettings" -location "Website 1"
            -prov "RsaProtectedConfigurationProvider"
    

    就个人而言,我发现使用-pef 开关更容易,因为我可以直接指向网络应用程序的物理目录。

    Encrypting Configuration Information Using Protected Configuration 上关注 MSDN 的教程。我已经多次使用它,并且在进行加密时还没有遇到问题。

    【讨论】:

    • 感谢您的回复。 C:\>aspnet_regiis -pe "appSettings" -location "web.config" -prov "RsaProtectedConfigurationProvider" 我已经在其他几台机器上这样做了。有用。所以问题不在于命令行。问题是关键。这台特定机器的密钥有问题。
    【解决方案3】:

    您需要将“管理员”更改为运行 ASP.NET 服务的帐户。因为,很可能,您没有将 ASP.NET 作为管理员服务帐户运行。如果是,那么您应该重新考虑您的决定。

    例如,这是我使用的:

     aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT Authority\Network Service"
    

    aspnet_regiis -pa "NetFrameworkConfigurationKey" "ASPNET"
    

    然后对于加密,我使用:

      aspnet_regiis -pef "connectionStrings"
    

     aspnet_regiis -pef "appSettings"
    

    【讨论】:

    • 感谢您的回复。 aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT Authority\Network Service" 或 aspnet_regiis -pa "NetFrameworkConfigurationKey" "ASPNET" 无论我提供什么帐户。它返回失败消息。添加 ACL 以访问 RSA 密钥容器... 未找到 RSA 密钥容器。失败!
    【解决方案4】:

    在上述命令的错误消失之前,我必须找到安装证书的文件夹并获得所有权/授予权限。错误说找不到密钥容器,但实际上只是我没有证书的权限。就我而言,我从其他人那里继承了一台开发机器,并且需要先授予自己对文件的权限,然后才能运行必要的命令。

    我曾希望对 cert 文件夹位置、详细步骤等给出更详细的回复,但没有时间,只想说明我在我的场景中必须做的事情。

    【讨论】:

      猜你喜欢
      • 2010-11-05
      • 2010-10-21
      • 2010-11-07
      • 1970-01-01
      • 2014-10-26
      • 2011-01-31
      • 2010-10-21
      • 1970-01-01
      • 2011-12-12
      相关资源
      最近更新 更多