views:

417

answers:

3

Having problem with encryption. I gave full permissions to all users to RSA folders. I did

C:\>aspnet_regiis -pe "appSettings" -location "web.config" -prov "RsaProtectedCo
nfigurationProvider"
Encrypting configuration section...
An error occurred executing the configuration section handler for appSettings.

Failed to encrypt the section 'appSettings' using provider 'RsaProtectedConfigur
ationProvider'. Error message from the provider: Object already exists.

Failed!

Then I did

C:\>aspnet_regiis -pa "NetFrameworkConfigurationKey" "administrator"
Adding ACL for access to the RSA Key container...
The RSA key container was not found.
Failed!

Followed by

C:\>aspnet_regiis -pc "NetFrameworkConfigurationKey" -exp
Creating RSA Key container...
The RSA key container could not be opened.
Failed!

Nothing is working for me.

Can anyone help?

Thanks

+1  A: 
C:\>aspnet_regiis -pe "appSettings" -location "web.config"
       -prov "RsaProtectedConfigurationProvider"

In this line your location is incorrect. When you use the -pd switch location is based on IIS's application paths and web.config is assumed as the point of encryption.

So for example if you have an application named "Website 1" and another named "Website 2" in IIS, and you want the web.config in "Website 1" to be encrypted you would use this line:

C:\>aspnet_regiis -pe "appSettings" -location "Website 1"
        -prov "RsaProtectedConfigurationProvider"

Personally, I found it easier to use the -pef switch as I can point directly to the web app's physical directory.

Follow MSDN's tutorial on Encrypting Configuration Information Using Protected Configuration . I've used it multiple times and have yet to have an issue doing encyrption.

Gavin Miller
Thank you for your reply.C:\>aspnet_regiis -pe "appSettings" -location "web.config" -prov "RsaProtectedConfigurationProvider" I have done this on several other machines. It works. So the issue is not the command line. The issue is the key. Something is wrong in this specific machine regarding the key.
BKarms
+1  A: 

You need to change "administrator" to whatever the account your ASP.NET service is running as. Because, chances are, you aren't running ASP.NET as administrator service account. If you are, then you should reconsider your decision.

For example, here's what I use:

 aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT Authority\Network Service"

or

aspnet_regiis -pa "NetFrameworkConfigurationKey" "ASPNET"

Then for encryption, I use:

  aspnet_regiis -pef "connectionStrings"

or

 aspnet_regiis -pef "appSettings"
Jim W
Thank you for your reply. aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT Authority\Network Service" or aspnet_regiis -pa "NetFrameworkConfigurationKey" "ASPNET" No matter what account i give. It returns failure message. Adding ACL for access to the RSA Key container... The RSA key container was not found. Failed!
BKarms
A: 

Thanks for the step aspnet_regiis -pa "NetFrameworkConfigurationKey" "ASPNET" is working for me and i am able to login my site through iis.. thanks for support

sharavanakkumar