Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.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
Encryption 使用可导出密钥提供程序加密外部存储的应用程序块_Encryption_Enterprise Library_Aspnet Regiis.exe - Fatal编程技术网

Encryption 使用可导出密钥提供程序加密外部存储的应用程序块

Encryption 使用可导出密钥提供程序加密外部存储的应用程序块,encryption,enterprise-library,aspnet-regiis.exe,Encryption,Enterprise Library,Aspnet Regiis.exe,我花了很长时间试图弄清楚如何加密存储在名为dev_entlib.config的外部文件中的应用程序块 我可以在entlib(4.1)中看到,可以使用默认的保护提供程序来加密块,但是,我确实需要在不同的服务器上部署此应用程序,因此我需要将用于加密应用程序块的密钥提供程序导出到这些服务器 到目前为止,我所做的是向.net v2.0*任意文件夹(以及所有目标服务器)中的machine.config文件添加一个自定义保护的配置提供程序 自定义提供程序如下所示 <add name="MyCompan

我花了很长时间试图弄清楚如何加密存储在名为dev_entlib.config的外部文件中的应用程序块

我可以在entlib(4.1)中看到,可以使用默认的保护提供程序来加密块,但是,我确实需要在不同的服务器上部署此应用程序,因此我需要将用于加密应用程序块的密钥提供程序导出到这些服务器

到目前为止,我所做的是向.net v2.0*任意文件夹(以及所有目标服务器)中的machine.config文件添加一个自定义保护的配置提供程序

自定义提供程序如下所示

<add name="MyCompanyProvider" 
    type="System.Configuration.RsaProtectedConfigurationProvider, 
          System.Configuration, Version=2.0.0.0, Culture=neutral, 
          PublicKeyToken=b03f5f7f11d50a3a,
         processorArchitecture=MSIL"
    keyContainerName="MyKey" 
    useMachineContainer="true" />
然后将该密钥文件复制到我的sysTest服务器,并将其导入其中,并授予“NT Authority\Network Services”和“ASPNET”访问权限

然后,我复制加密的web.config和dev_entlib.config,并尝试在一个小页面中显示连接字符串,该页面使用.net ConfigurationManager获取ConnectionString集合并在页面上显示它们。此页面在IIS下运行,进程的标识为“NT Authority\Network Services”

问题是,它不起作用!存在错误数据错误或“无法使用提供程序MyCompanyProvider解密”

这种方法在我看来似乎合乎逻辑,但仍然失败


有人有其他建议吗?

这似乎还不可能。我的解决方案是将块作为web.config的一部分进行加密,然后将这些块复制并粘贴到外部entLib.config文件中。然后,应该能够使用导出的密钥在目标服务器上解密这些块。

使用企业库配置工具,使用自定义RSA密钥容器加密外部企业库配置文件。
  • EntLib(4.1)使用默认的保护提供程序rsaptectedconfigurationprovider。但是,可以删除配置文件中的此提供程序,并将其替换为您自己的具有相同名称的提供程序,然后可以指向您的自定义密钥提供程序:“MyKey”
  • 您应该在配置文件中添加此configProtectedData部分,该配置文件包含要加密的区域(例如,您的外部文件:*dev_entlib.config*)。您根本不需要修改machine.config文件
  • 然后,您可以从数据访问应用程序块ProtectionProvider的企业库配置应用程序中选择RsaProtectedConfigurationProvider
  • 如果您使用的是Vista、Windows 7、Windows 2008,则必须以管理员身份运行来打开此EntLibConfig.exe。
    • 否则,您将得到一个错误:
      • 无法使用提供程序“RsaProtectedConfigurationProvider”加密“ConnectionString”部分。来自提供程序的错误消息:对象已存在。
  • 然后,您可以将此加密的*dev_entlib.config*以及web.config配置文件复制到sysTest服务器。在sysTest服务器上使用Enterprise Library Configuration tool打开web.config文件,应而不是获取错误:
    • 无法使用提供程序“RsaProtectedConfigurationProvider”进行解密。来自提供商的错误消息:数据错误。
web.config 此文件几乎为空,仅指向外部数据配置文件:

<!-- web.config -->
<configuration>
  <configSections>
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </configSections>
  <enterpriseLibrary.ConfigurationSource selectedSource="External Data Configuration File Source">
    <sources>
      <add name="External Data Configuration File Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        filePath="dev_entlib.config" />
    </sources>
  </enterpriseLibrary.ConfigurationSource>
</configuration>

(AvanadeSupport,2010年12月8日晚上11:37)
  • (2007年7月9日下午1时15分)
  • (需要将版本更改回2.0.0.0)
  • 我希望这篇文章描述了您遇到的错误消息以及如何修复它

    <!-- web.config -->
    <configuration>
      <configSections>
        <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </configSections>
      <enterpriseLibrary.ConfigurationSource selectedSource="External Data Configuration File Source">
        <sources>
          <add name="External Data Configuration File Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            filePath="dev_entlib.config" />
        </sources>
      </enterpriseLibrary.ConfigurationSource>
    </configuration>
    
    <!-- dev_entlib.config -->
    <configuration>
        <configSections>
            <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
     </configSections>
        <dataConfiguration defaultDatabase="MyConnectionStringName" />
     <connectionStrings>
      <add name="cnHnicMediaLibrary" connectionString="Server=MyDbServer; Database=MyDbName; Integrated Security=SSPI"
       providerName="System.Data.SqlClient" />
     </connectionStrings>
      <configProtectedData>
        <providers>
          <remove name="RsaProtectedConfigurationProvider" />
          <add    name="RsaProtectedConfigurationProvider"
            keyContainerName="MyKey"
            useMachineContainer="true"
            description="Uses our own encryption key container so that it will work in a Web Farm setting. We need to trick Enterprise Library, which wants to use the default RsaCryptoServiceProvider to encrypt and decrypt, by replacing this default provider with our own while this configuration is processed!"
            type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
      </configProtectedData>
    </configuration>