Tuesday, May 6, 2008

Encrypting the identity tag in web.config

In the web.config file, under you have

Here's a sample command line that encrypts the identity tag. This is all one line by the way...

%windir%\microsoft.net\framework\v2.0.50727 \aspnet_regiis -pef system.web/identity d:\locationToMyWebsite\webSiteName -prov DataProtectionConfigurationProvider

To undo it, just replace "pef" with "pdf" and remove the -prov switch. The "e" is for encrypt, and the "d" is for decrypt. Also replace the v2.0.50727 to the version of .Net you're using if it's not 2.0.

You could go through the trouble of creating your own provider, exporting keys to XML files for use on a server farm, etc. but if you're just running an app on one server, take the easy road and just use the DataProtectionConfigurationProvider. Keep in mind that you need to deploy first, then do the encryption because if you do it on one machine, then move it to another, it won't work.

0 comments: