cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Encrypting Decrypting web.config

So I have went through the steps to encrypt my connection strings and machine key, as seen here.

 

When opening the page after its uploaded to the server I get the error.

Failed to decrypt using provider 'RsaProtectedConfigurationProvider'

 

So I followed this.

I exported the RSA key which I'm now supposed to import onto the server with command prompt, but my hosting doesn't include a command prompt.

I'm not really sure what to do at this point, any help would be appreciated.

2 REPLIES 2
New

Re: Encrypting Decrypting web.config

I'm also having this problem.  I called Godaddy to try to find out how to encrypt my connection strings, and the person who I spoke with seemed to not understand the question.  He kept saying there are no articles about that.  Yeah, that's why I was calling.  So I did some research and attempted to run the following code on Godaddy's server based on this article from Microsoft.  
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/connection-strings-and-configuration-f...

// Open the Web.config file.
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");

// Get the connectionStrings section.
ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection;

// Toggle encryption.
if (section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
}
else
{
//section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider"); 
}

// Save changes to the Web.config file.
config.Save();

 

I got an error saying that I attempted to perform an operation that is disallowed on the server.  So that was a bust.  

 

Re: Encrypting Decrypting web.config

After searching for ages I finally found out that it is simply not possible. To be able to do it you need a machine key, which you need to do certain things on the system itself. And unless you are renting a dedicated server you have no access to a console.

 

I haven't tried to find an alternate solution for quite some time now, but I was thinking a couple of days ago maybe there is a way to at least grab passwords, and any other private data from a database using your own encryption/decryption.