Friday, June 17, 2005

How to use the ASP.NET utility to encrypt credentials

Use the Aspnet_setreg.exe utility to encrypt and to store these attribute values in the registry under a secure key.

1) Download and Run Aspnet_setreg.exe. The file is available for download from the Microsoft Download Center.

2) Encrypt the userName and password attributes to be used with the section. (You can also do this for the other sections that are mentioned in this article). To do this, type the following command at the command line:

aspnet_setreg.exe -k:SOFTWARE\MY_SECURE_APP\identity -u:"yourdomainname\username" -p:"password"

This command encrypts the userName and password attributes, creates registry keys at any location that you specify, and then stores the attributes in those registry keys. This command also generates output that specifies how to change your Web.config or Machine.config file so that ASP.NET will use these keys to read that information from the registry.

3) Modify the corresponding configuration file to point to these registry keys. If these values must be used in the section, the resulting section resembles the following:

4) Grant Read permissions to the Aspnet_wp.exe process account. Grant Read permissions to the Aspnet_wp.exe process account. - yourservername\ASPNET or yourservername\NetWorkService when using Windows Server 2003 (IIS 6.0).

Happy Coding!

No comments: