c# - The RSA key container could not be opened for one of two sections -


i have encrypted 2 sections of webconfig file, 1 called connectionstrings , other useraccount using same provider.

in code connectionstring section decrypted fine without problem when comes decrypt second section called useraccounts error.

here exact error message:

failed decrypt using provider 'aqueductdevprovider'. error message provider: rsa key container not opened.

your appreciated.

thanks

here code in web config file

<configprotecteddata>     <providers>         <add name="aqueductdevprovider"              type="system.configuration.rsaprotectedconfigurationprovider, system.configuration, version=2.0.0.0,&#xd;&#xa;culture=neutral, publickeytoken=b03f5f7f11d50a3a,&#xd;&#xa;processorarchitecture=msil"              keycontainername="aqueductdevkeys"              usemachinecontainer="true" />     </providers> </configprotecteddata>  <connectionstrings configprotectionprovider="aqueductdevprovider">     <encrypteddata type="http://www.w3.org/2001/04/xmlenc#element" xmlns="http://www.w3.org/2001/04/xmlenc#">         <encryptionmethod algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />         <keyinfo xmlns="http://www.w3.org/2000/09/xmldsig#">             <encryptedkey xmlns="http://www.w3.org/2001/04/xmlenc#">                 <encryptionmethod algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />                 <keyinfo xmlns="http://www.w3.org/2000/09/xmldsig#">                     <keyname>rsa key</keyname>                 </keyinfo>                 <cipherdata>                 <ciphervalue></ciphervalue>                 </cipherdata>             </encryptedkey>         </keyinfo>         <cipherdata>                 <ciphervalue></ciphervalue>         </cipherdata>     </encrypteddata> </connectionstrings> <useraccounts configprotectionprovider="aqueductdevprovider">     <encrypteddata type="http://www.w3.org/2001/04/xmlenc#element" xmlns="http://www.w3.org/2001/04/xmlenc#">         <encryptionmethod algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />         <keyinfo xmlns="http://www.w3.org/2000/09/xmldsig#">             <encryptedkey xmlns="http://www.w3.org/2001/04/xmlenc#">                 <encryptionmethod algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />                 <keyinfo xmlns="http://www.w3.org/2000/09/xmldsig#">                     <keyname>rsa key</keyname>                 </keyinfo>                 <cipherdata>                 <ciphervalue></ciphervalue>                 </cipherdata>             </encryptedkey>         </keyinfo>         <cipherdata>                 <ciphervalue></ciphervalue>         </cipherdata>     </encrypteddata> </useraccounts> 

this how trying access information useraccounts section

system.configuration.configurationmanager.appsettings["adminname"]; there key in useraccounts called adminname encrypted

i able figure out, apparently when code trying retrieve custom section running under wrong user account(which different when tried retrieve connectionstrings). used following code find out user account code running under when trying access custom encrypted section.

<% response.write(system.security.principal.windowsidentity.getcurrent().name);%> 

result nt authority\iusr

after had run following command under directory

c:\windows\microsoft.net\framework\v4.0.30319>  aspnet_regiis.exe -pa "aqueductdevkeys" "nt authority\iusr" 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -