Web.config Encryption and Decryption
-
Hi there, I want to encrypt my site web.config file for security purposes and why searching codeproject for this topic, I found this useful link https://www.codeproject.com/Tips/795135/Encrypt-ConnectionString-in-Web-Config I followed the steps and was able to encrypt the connection strings on my local system. Now, I copied the web.config file to my host server root directory. Then on loading the site, I got this error-: Parser Error Message: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: Bad Data. Then I tried searching the net and codeproject for solution but none was found by me pointing to error why uploaded to server. Maybe am not using the right keywords! However, I came across a link that suggested I should change Or Which I did but no luck. But I believe someone here on codeproject has the solution. So my question is, how can I make this to work after uploading to server? Note: Am using shared hosting for now so I don't have admin rights to do anything on the server. Thanks in advance!
-
Hi there, I want to encrypt my site web.config file for security purposes and why searching codeproject for this topic, I found this useful link https://www.codeproject.com/Tips/795135/Encrypt-ConnectionString-in-Web-Config I followed the steps and was able to encrypt the connection strings on my local system. Now, I copied the web.config file to my host server root directory. Then on loading the site, I got this error-: Parser Error Message: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: Bad Data. Then I tried searching the net and codeproject for solution but none was found by me pointing to error why uploaded to server. Maybe am not using the right keywords! However, I came across a link that suggested I should change Or Which I did but no luck. But I believe someone here on codeproject has the solution. So my question is, how can I make this to work after uploading to server? Note: Am using shared hosting for now so I don't have admin rights to do anything on the server. Thanks in advance!
Did you read the article you've linked to?
Quote:
... if you encrypt your Config file, then your machine would store your keys and if you copy the Config file to a different system and try to decrypt it, then you might get an error.
The encryption keys are stored on the machine where the file was encrypted. You need to upload a decrypted version of the config file and run the encryption commands on the server where you application will be running. You can't encrypt on one computer and copy the encrypted file to another computer.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Did you read the article you've linked to?
Quote:
... if you encrypt your Config file, then your machine would store your keys and if you copy the Config file to a different system and try to decrypt it, then you might get an error.
The encryption keys are stored on the machine where the file was encrypted. You need to upload a decrypted version of the config file and run the encryption commands on the server where you application will be running. You can't encrypt on one computer and copy the encrypted file to another computer.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Ok thanks. Just as I stated on the original, I don't have access to command prompt on the server cos is a shared host. How about if I create it using code behind on the server, will this error persist? Once again, thanks for your help!
-
Ok thanks. Just as I stated on the original, I don't have access to command prompt on the server cos is a shared host. How about if I create it using code behind on the server, will this error persist? Once again, thanks for your help!
If your ASP.NET application has access to write to the config file, you could try encrypting the config using code: Programmatically Encrypt the Connection String In ASP.NET Applications[^] Otherwise, you'll need to talk to your hosting provider to see what your options are.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
If your ASP.NET application has access to write to the config file, you could try encrypting the config using code: Programmatically Encrypt the Connection String In ASP.NET Applications[^] Otherwise, you'll need to talk to your hosting provider to see what your options are.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
K. Thanks
-
Hi there, I want to encrypt my site web.config file for security purposes and why searching codeproject for this topic, I found this useful link https://www.codeproject.com/Tips/795135/Encrypt-ConnectionString-in-Web-Config I followed the steps and was able to encrypt the connection strings on my local system. Now, I copied the web.config file to my host server root directory. Then on loading the site, I got this error-: Parser Error Message: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: Bad Data. Then I tried searching the net and codeproject for solution but none was found by me pointing to error why uploaded to server. Maybe am not using the right keywords! However, I came across a link that suggested I should change Or Which I did but no luck. But I believe someone here on codeproject has the solution. So my question is, how can I make this to work after uploading to server? Note: Am using shared hosting for now so I don't have admin rights to do anything on the server. Thanks in advance!
I have finally solved this through the help of many valuable suggestions. The problem I was having was as a result of not granting write and read permission to ASP.net.