Posted By: Robert Shelton, Jr. | Nov 7th, 2005 @ 3:35 PM | 37,021 Views | 6 Comments

Federal Developer Evangelist, Robert Shelton, Jr., takes you through a short (8 minute) demonstration of how Encrypt portions of your web.config with ASP 2.0 (Visual Studio 2005).  This walkthrough shows you how to encrypt two sections of your web.config (AppSettings and ConnectionStrings) with the DPAPI (DataProtectionConfigurationProvider).  In addition to these two sections, you can also encrypt your Identity and SessionState sections.

 


 

My blog URL: http://sheltonblog.com 

 

Channel 9 Article: Encrypt Configuration Sections in ASP.NET 2.0 Using RSA

MSDN Article: How To: Encrypt Configuration Sections in ASP.NET 2.0 Using DPAPI


Please check out some of my other screencast by clicking this search link.  Including a 3 part series on programming Active Directory with Visual Studio 2005.

 

~ Robert Shelton, Jr.

Media Downloads:
Rating:
1
0
guercheLE
guercheLE
guerchele
Dear Robert Shelton, Jr.,

If I encrypt a web.config file using aspnet_regiis.exe with -pe or -pef option, get encrypted web.config file and take it to another machine, run aspnet_regiis.exe with -pd or -pdf option, what do I get? A plain file or an error? Do the encryption algorithm uses the PKI or any salt to encrypt so that if you exchange windows accounts or machine, the user does not get to the plain file?
jrs
jrs
This was a nice demo Robert.

I'm curous it you have to encrypt the config files for every separate installation of the webapp (like you did in the video). I guess the encryption/decryption depends on some machine specific key.

How about web application farms. Is there a way to encrypt the config file once and deploy the decrypted version to all instances in the farm?

Regards,

Johan Sundström
Very informative.  However, what the significance of the "configProtectionProvider" attribute not being defined and the error associated with the "EncryptedData" tag in your Screencast.  Should they just be ignored?
I have tried this command with failed results:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "connectionStrings" "C:\MyFolder\EncryptionDemo" –prov "DataProtectionConfigurationProvider"

All I got after attempting to run this command from a windows cmd prompt was the aspnet_regiis help screen.  What am I missing?  I have even ensured my web.config file is not read only and that the aspnet user has full control on the security permissions.  Please help.  Thanks you.

Sincerely,

Ron Breeding Sad

cloak13PLAGUE
cloak13PLAGUE
Greatest Video Game Ever!
Thanks very much for the demo. I would like to hit on the question that the one user earlier asked. I think what the user was asking is if some how some one were able to retrieve that web config file could they take it to another machine and run the decrypt on it and get the information out of the file?

For example, Johnny Cracker steals the web.config file from my site some how. Could they run -pd on their home IIS 6 server and decrypt the file exposing the information we are trying to hide?

Another possible scenario is that I have a web farm. If server A which I encrypted the file on dies can I decrypt the file on server B?

Just curious,
Thanks again for posting!

Tim Kulp
Microsoft Communities