Encrypting app.config

Topics: Data Access Application Block, Enterprise Library Core
Apr 30, 2008 at 12:45 PM
I am using Enterprise library v3.1 for developing a windows application. its working well.
but there is a security issue, when i deploy this application on client machine the applicationname.exe.config contains connectionString and other secure information. My question is how I can secure applicationname.exe.config file so that anyone could not open it.

I have tried encryption of Data Access Application Block (with both providers RSA & DPAPI) using enterprise library configuration tool. but when I deploy on client machine it gives these errors:

System.Configuration.ConfigurationErrorsException: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not
be opened. (C:\Program Files\Tesst APP\Test APP.exe.config line 30) --->

System.Configuration.ConfigurationErrorsException: The RSA key container could not be opened.
System.Configuration.ConfigurationErrorsException: Failed to decrypt using provider 'DataProtectionConfigurationProvider'. Error message from the provider: Key not valid for use in specified state. (Exception from HRESULT: 0x8009000B) (C:\Program Files\Test APP\Test APP.exe.config line 17) ---> System.Runtime.InteropServices.COMException (0x8009000B): Key not valid for use in specified state. (Exception from HRESULT: 0x8009000B).

Also app.config contains
<machineKey validationKey="somevalue" decryptionKey="somevalue" validation="SHA1" />
I want it should be also encrypted.

I will be very thankful for any help.

Apr 30, 2008 at 9:56 PM
Did you export the RSA Key from the machine where you encrypted your config file, to the machine, where you are trying to decrypt it ? I guess you are missing that peice.
May 5, 2008 at 5:25 PM
Here's some information on how to export and import RSA key containers http://msdn.microsoft.com/en-us/library/yxw286t2.aspx.

Fernando