Programming Keys is blog for all Programming and technology related articles

Friday, September 8, 2017

How to Encrypt Web config in asp.net mvc

1.      Create RSA key container (Development machine).
a.       Run CMD as Administrator

2.      Export the RSA key container (Development machine).

3.      Prepare the web.config file for encryption (Development machine).
a.        Add the following code to the web.config file as a child of the <configuration> node
    <providers>
      <add name="Neorithm" type="System.Configuration.RsaProtectedConfigurationProvider,&#xD;&#xA;          System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,&#xD;&#xA;          processorArchitecture=MSIL"
      keyContainerName="InternetBanking"
      useMachineContainer="true"/>
    </providers>
  </configProtectedData>

4.       Encrypt the web.config file (Development machine).
a.       For connectionStrings
b.       For appSettings

The following steps will be performed on each machine where your web-app will be deployed.
5.      Import the RSA Key container into the machine. (Deployment machine)
Copy the “keys.xml” file to the machine where the app needs to run. Run the following command to import the keys:
To Decrypt Web.Config


To Encrypt –

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pef "appSettings" "E:\Model\EBS" -prov "Neorithm"


Share:

0 comments:

Post a Comment