locked
C# RSA Decryption Issue RRS feed

  • Question

  • User1690819570 posted

    I tried encrypting connection string on my machine A .

    It was successful .

    I exported the key and the encrypted web config to some other machine B .

    It tried to decrypt the web config using that exported key as an Administrator .


    But it failed saying

    C:\Windows\system32>cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319
    
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -pi "NewEncryptKey
    " "C:\Users\abalawan\Desktop\NewStuartCN\encryptkeynew.xml"
    Importing RSA Keys from file..
    Succeeded!
    
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -pa "NewEncryptKey
    " "NT AUTHORITY\NETWORK SERVICE"
    Adding ACL for access to the RSA Key container...
    Succeeded!
    
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -pdf "connectionSt
    rings" "C:\Users\abalawan\Desktop\NewStuartCN"
    Decrypting configuration section...
    Failed to decrypt using provider 'NewEncryptProvider'. Error message from the pr
    ovider: Not enough storage is available to process this command.
    (C:\Users\abalawan\Desktop\NewStuartCN\web.config line 35)
    
    Not enough storage is available to process this command.
    
    Failed!



    What am I missing here ? Any help will be much appreciated.

    Wednesday, September 9, 2015 5:08 PM

All replies

  • User585756558 posted

    @Chiranjib_Na...    welcome to forums.iis.net

    i see you've cross posted this here:  Home/ASP.NET Forums/.NET Languages/C#/C# RSA Web Config Decryption Issue

    Please check the suggestions that i posted there.

    Thursday, September 10, 2015 5:29 AM
  • User1183424175 posted

    Hi,

    Maybe you forget to edit your web.config on other PC:

    <configProtectedData >
        <providers>
    

    For more information, please refer to the document:

    http://www.codeproject.com/Articles/13936/Managing-Connection-Strings-for-Web-Farms-in-ASP-N

    Thursday, September 10, 2015 5:39 AM
  • User1690819570 posted

    Hi,

    The encrypted web.config which I copied to the other machine already had the container in place . It looks like 

     <configProtectedData>
    	<providers>
    		<clear />
    		<add name="NewEncryptProvider"  type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"  keyContainerName="NewEncryptKey" useMachineContainer="true"/>
    	</providers>
    </configProtectedData>
    
      <connectionStrings configProtectionProvider="NewEncryptProvider">
        <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" ..............

    I also copied the key and tried to run the commands with Administrator privileges. :(
    What else can be done ?


    Thursday, September 10, 2015 6:34 AM