【问题标题】:Failed to encrypt the section 'connectionStrings' using provider 'RsaProtectedConfigurationProvider无法使用提供程序“RsaProtectedConfigurationProvider”加密“connectionStrings”部分
【发布时间】:2013-03-12 15:23:14
【问题描述】:

未能使用提供程序“RsaProtectedCo”加密“connectionStrings”部分 nfigurationProvider'。来自提供者的错误消息:对象已存在。

我按照http://msdn.microsoft.com/en-us/library/2w117ede.aspx 中的指南进行操作,但在授予 ASP.NET 身份访问 RSA 密钥容器的第 3 步中,它说我的身份是我的工作组\用户名,我的网络中没有模拟。配置文件虽然

我正在使用我的机器使用 asp_regiis 加密 web.config,然后使用 Visual Studio 进行调试,然后出现此错误

【问题讨论】:

  • 可能重复:From other post 实际上以管理员身份运行 CMD 也为我解决了这个问题!
  • 在管理员模式下启动命令提示符,然后继续。应该解决问题。

标签: aspnet-regiis.exe


【解决方案1】:

要使用 RsaProtectedConfigurationProvider,您需要以管理员身份启动命令提示符或 Visual Studio。

对于 DataProtectionConfigurationProvider,它不需要在管理员权限下运行。

【讨论】:

  • 我的经验是,您不能只以管理帐户登录并启动通用命令提示符。当我这样做时,aspnet_regiis 失败。我实际上必须在 cmd.exe 或 Visual Studio 命令提示符上执行“以管理员身份运行”。然后 aspnet_regiis 按预期工作。
  • 是的,您需要提升到管理员权限,但这取决于您的系统用户设置(因为在某些情况下,登录的管理员不需要提升应用程序)才能使这些更改机器。
  • 这一直困扰着我。
  • 为了让人们清楚这一点,如果您正在使用: ProtectSection("RsaProtectedConfigurationProvider") 您的用户必须具有管理员权限。因为这在许多公司中是不允许的,也不是 Windows 中的默认行为。请改用: ProtectSection("DataProtectionConfigurationProvider") 普通用户可以打开加密文件。
  • 哇!多么愚蠢的错误信息。谁会猜到“对象已经存在”实际上意味着“没有足够的访问权限”。
【解决方案2】:

您可以使用 RsaProtectedConfigurationProvider 创建自己的提供程序来加密您的 web.xml,而无需管理员权限。

  1. 创建密钥库:

    aspnet_regiis -pc "MyKeyStore" -exp

  2. 为任何用户授予读取权限:

    aspnet_regiis -pa "MyKeyStore" "域/用户"

  3. 在您的 web.config 中添加一个提供程序部分

    <configProtectedData>
    <providers>
        <add name="MyRSAProvider" type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"keyContainerName="MyKeyStore"useMachineContainer="true" />
    </providers>
    </configProtectedData>
    
  4. 加密您的配置部分:

    aspnet_regiis -pef "configSection" "c:\pathToWebConf" -prov "MyRSAProvider"

来源:

Create RSA key container and provider

Encrypt configuration

【讨论】:

    【解决方案3】:

    这发生在我的一台服务器上,整个服务器试图将网络应用程序从 c 驱动器移动到另一个驱动器。

    因为我已加密驱动器 C 上的 web.config 部分并将其移动到另一个驱动器,它阻塞了提供程序,导致它无法加密该部分,因为它认为它已经存在。

    我还在努力修复它。

    【讨论】:

      猜你喜欢
      • 2013-04-14
      • 1970-01-01
      • 2011-08-13
      • 2010-12-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-15
      • 1970-01-01
      • 2018-01-07
      相关资源
      最近更新 更多