Zieglers

Just little about C#, .NET, SQL Server, SharePoint and SAP

Encrypt / Decrypt Connection Strings in web.config

Posted by zieglers on October 27, 2008

Key Maker

Key Maker

ASP.NET stores all the configuration information in plain text files called web.config and machine.config files. We store all vital information including database connection strings, user names, passwords for the databases. Thus you end up storing all sensitive information in vulnerable plain text files which is nothing but security compromise.

If you want to secure your connection strings and application settings, here is an easy way to encrypt / decrypt sections in web.config file. You can use aspnet_regiis.exe command line tool as follows:

Encrypting appSettings and connectionStrings sections in web.config :

Aspnet_regiis.exe –pef “appSettings” “<PathToWebSiteDir>” –prov “DataProtectionConfigurationProvider”

Aspnet_regiis.exe –pef “connectionStrings” “<PathToWebSiteDir>” –prov “DataProtectionConfigurationProvider” 

Decrypting appSettings and connectionStrings sections in web.config :

Aspnet_regiis.exe –pdf “appSettings” “<PathToWebSiteDir>”

Aspnet_regiis.exe –pdf “connectionStrings” “<PathToWebSiteDir>”

zieglers

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: