Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>Encrypt external Enterprise Library configuration files with your custom RSA key container using the Enterprise Library Configuration tool.</h2> <ul> <li>EntLib (4.1) uses the default protection provider <em>RsaProtectedConfigurationProvider</em>. But it is possible to remove this provider within your configuration file and replace it with your own with the same name which can then point to your custom key provider: "<em>MyKey</em>".</li> <li>You should add this <em>configProtectedData</em> section in the configuration file that has the region that you want to encrypt (e.g. your external file: *dev_entlib.config*). You do not need to modify the <em>machine.config</em> file at all.</li> <li>You can then choose the <em>RsaProtectedConfigurationProvider</em> from the Enterprise Library Configuration application for the <em>Data Access Application Block</em> ProtectionProvider. </li> <li>You have to open this <em>EntLibConfig.exe</em> with <em>Run as administrator</em> if you are on Vista, Windows 7, Windows 2008. <ul> <li>Otherwise you will get an error: <ul> <li><code>Failed to encrypt the section 'connectionStrings' using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: Object already exists.</code></li> </ul></li> </ul></li> <li>You can then copy this encrypted *dev_entlib.config* along with the <em>web.config</em> configuration file to your <em>sysTest</em> server. Open up the <em>web.config</em> file with Enterprise Library Configuration tool on that <em>sysTest</em> server should <strong>not</strong> get the error: <ul> <li><code>Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: Bad Data.</code></li> </ul></li> </ul> <h3>web.config</h3> <p>This file is pretty much empty and just points to the external Data Configuration file:</p> <pre><code>&lt;!-- web.config --&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt; &lt;/configSections&gt; &lt;enterpriseLibrary.ConfigurationSource selectedSource="External Data Configuration File Source"&gt; &lt;sources&gt; &lt;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" /&gt; &lt;/sources&gt; &lt;/enterpriseLibrary.ConfigurationSource&gt; &lt;/configuration&gt; </code></pre> <h3>dev_entlib.config</h3> <p>This file has the connection strings and the protection provider with which it should be encrypted with:</p> <pre><code>&lt;!-- dev_entlib.config --&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt; &lt;/configSections&gt; &lt;dataConfiguration defaultDatabase="MyConnectionStringName" /&gt; &lt;connectionStrings&gt; &lt;add name="cnHnicMediaLibrary" connectionString="Server=MyDbServer; Database=MyDbName; Integrated Security=SSPI" providerName="System.Data.SqlClient" /&gt; &lt;/connectionStrings&gt; &lt;configProtectedData&gt; &lt;providers&gt; &lt;remove name="RsaProtectedConfigurationProvider" /&gt; &lt;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" /&gt; &lt;/providers&gt; &lt;/configProtectedData&gt; &lt;/configuration&gt; </code></pre> <h3>Based on:</h3> <ul> <li><a href="http://entlib.codeplex.com/discussions/237555" rel="nofollow">http://entlib.codeplex.com/discussions/237555</a> (AvanadeSupport, Dec 8 2010 at 11:37 PM) </li> <li><a href="http://entlib.codeplex.com/discussions/10300" rel="nofollow">http://entlib.codeplex.com/discussions/10300</a> (shane2007, Jul 9 2007 at 1:15 PM) </li> <li><a href="http://entlib.codeplex.com/discussions/213998" rel="nofollow">http://entlib.codeplex.com/discussions/213998</a> (need to change the version back to 2.0.0.0) </li> </ul> <p>I hope that this described the error message that you had and how to fix it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload