Web. config encryption and decryption

Source: Internet
Author: User
Tags connectionstrings
Use the command line tool aspnet_regiis.exe

You can also use the aspnet_regiis.exe command line tool to encrypt and decrypt the Web. config file configuration section. You can find this tool in the "% windowsdir % \ Microsoft. NET \ framework \ version" directory. To encrypt a section in the web. config file, you can use the dpapi machine key in this command line tool, as shown below:

Common form of encrypting the Web. config file of a specific website:

Aspnet_regiis.exe-Arg section physical_directory-prov provider

Or:

Aspnet_regiis.exe-PE section-app virtual_directory-prov provider

Encrypt the specific instance of the web. config file of a specific website:

Aspnet_regiis.exe-Arg "connectionstrings" "C: \ Inetpub \ wwwroot \ mysite"-prov "dataprotectionconfigurationprovider"

Or:

Aspnet_regiis.exe-pe "connectionstrings"-app "/mysite"-prov "dataprotectionconfigurationprovider"

Common form of decrypting the Web. config file of a specific website:

Aspnet_regiis.exe-PDF section physical_directory

Or:

Aspnet_regiis.exe-Pd section-app virtual_directory

Decrypts a specific instance of the web. config file of a specific website:

Aspnet_regiis.exe-PDF "connectionstrings" "C: \ Inetpub \ wwwroot \ mysite"

Or:

You can also specify that aspnet_regiis.exe is used to encrypt/decrypt the machine. config file.

[Prompt] encrypt configuration settings in ASP. NET version 1.x

To protect configuration settings in ASP. NET version 1.x, developers need to encrypt and store sensitive settings in the web server registry, and store them in a "strong" key mode. The configuration file does not store encrypted content (such as ASP. NET 2.0), but only contains a reference to the registry key that stores the encrypted value. For example:

<Identity impersonate = "true"
Username = "Registry: HKLM \ SOFTWARE \ my_secure_app \ identity \ aspnet_setreg, username"
Password = "Registry: HKLM \ SOFTWARE \ my_secure_app \ identity \ aspnet_setreg, password"/>

Microsoft released the aspnet_setreg.exe command line tool for developers to encrypt sensitive configuration information and move it to a "strong" Registry portal. Unfortunately, this tool only works for specific configuration settings; in contrast, ASP. NET 2.0 allows encryption of any configuration section.

For an ASP. NET 1.x ApplicationProgramFor more information about using aspnet_setreg.exe, see kb #32990 in msdn. Unfortunately, this command line program can only encrypt predefined sections in configuration settings, and does not allow you to encrypt your own database connection strings and other sensitive information.

Encrypted instance:
C: \ windows \ microsoft. Net \ framework \ v2.0.50727 \ aspnet_regiis-PDF connectionstrings I :\CodeRepository \ wt_projects \ websites \ website

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.