Web.config encryption error

Encryption issue. I gave full permissions to all users in the 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! 

Further

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

Nothing works for me.

Can anyone help?

thanks

+6
encryption rsacryptoserviceprovider
source share
4 answers

I had a problem with this error:

aspnet_regiis -pa "NetFrameworkConfigurationKey" "{Domain} {Username}"

The above line returned "RSA Key Container Not Found".

To fix this problem, I had to run Command Prompt as an administrator (go to Start> Accessories), then right-click "Command Prompt" and select "Run as Administrator ..."). I had to do this even if my account was an administrator account.

+9
source share
 C:\>aspnet_regiis -pe "appSettings" -location "web.config" -prov "RsaProtectedConfigurationProvider" 

Your location is incorrect on this line. When you use the -pd switch -pd based on IIS application paths and web.config is considered the encryption point.

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

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

Personally, it was easier for me to use the -pef switch, because I can point directly to the physical directory of the web application.

Follow the MSDN instructions for Encrypting configuration information using a secure configuration . I have used it several times and still have no problem using encyrption.

+1
source share

You need to change the “admin” to what works in your ASP.NET account. Since most likely you are not using ASP.NET as an administrator account. If so, then you should reconsider your decision.

For example, here 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" 
+1
source share

I had to find the folder in which the certificates are installed and get ownership / grant permissions before the errors with the above commands disappear. Errors say that the key container was not found, but in fact it was just that I did not have rights to the certificate. In my case, I inherited the development machine from someone else and I had to grant file permissions before I could execute the necessary commands.

I was hoping to give a more detailed answer with my folders, detailed steps, etc., but I didn’t have time and just wanted to note what I needed to do in my script.

0
source share

All Articles