【问题标题】:aspnet_regiis web.config encryption [Error message from the provider: Bad Data.]aspnet_regiis web.config 加密 [来自提供商的错误消息:错误数据。]
【发布时间】:2014-04-27 07:28:38
【问题描述】:

我正在尝试加密 Web 应用的 web.config,但该应用存在于 2 个不同的环境(阶段、生产)中,每个环境都应使用不同的密钥容器。

所以我在我的舞台配置中使用了这个加密标头:

<configProtectedData defaultProvider="ApplicationProvider">
<providers>
  <add name="ApplicationProvider"
    type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
    keyContainerName="ApplicationStageKeys"
    useMachineContainer="true"
    useOAEP="true"/>
</providers>

我的生产配置中的这个标题:

<configProtectedData defaultProvider="ApplicationProvider">
<providers>
  <add name="ApplicationProvider"
    type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
    keyContainerName="ApplicationProductionKeys"
    useMachineContainer="true"
    useOAEP="true"/>
</providers>

加密工作正常,但每次我尝试解密时,我都会收到以下错误,这让我无法想象......

C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis -pdf connectionStrings C:\Temp

Decrypting configuration section...
Failed to decrypt using provider 'ApplicationProvider'. Error message from the provider: Bad Data.
(C:\Temp\web.config line 75)

Bad Data.

Failed!

我已经在每台服务器上导入了密钥并为两者都设置了 ACL,但仍然不满意,还有其他人遇到过这个问题吗?

【问题讨论】:

    标签: asp.net web-applications encryption web-config rsa


    【解决方案1】:

    查看后我找到了一个修复方法,我们的安全人员要求我们将“useOAEP”标志设置为“true”,我删除了它,加密和解密工作完美!

    我希望我能解释为什么这会修复它,但是当您提供的所有信息都是愚蠢的错误消息(错误数据!)时,您不能完全期待一个聪明的解释。

    这是我们的加密标头现在的样子:

    <configProtectedData defaultProvider="ApplicationProvider">
    <providers>
    <add name="ApplicationProvider"
         type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
         keyContainerName="ApplicationProductionKeys"
         useMachineContainer="true"/>
    </providers>
    

    希望这将在其他人尝试加密时节省他们的发际线几英寸

    【讨论】:

      猜你喜欢
      • 2017-09-13
      • 1970-01-01
      • 2020-11-15
      • 2014-06-24
      • 1970-01-01
      • 2010-11-05
      • 1970-01-01
      • 2015-12-22
      • 1970-01-01
      相关资源
      最近更新 更多