CONNECT WITH ADCOMPLETE.COM    EMAIL NEWSLETTER  |  CONTACT US            +1-407-551-0777

How do I encrypt the database connection string in web.config?

  To encrypt the connection string section follow the steps,

1.  Launch a command prompt.  You can do this using Start/Run and entering CMD.

2. Switch to the folder where .net 4 is installed.  For example:

    cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

3. Type following command,

    aspnet_regiis.exe -pef “connectionStrings” C:\inetpub\wwwroot\affiliatewiz

    -pef indicates that the application is built as File System website.  The second argument is the name of configuration section needs to be encrypted. Third argument is the physical path where the web.config file is located.

   If Affiliate Wiz is installed as a sub folder of a web site, then you can use,

   aspnet_regiis.exe -pe “connectionStrings” -app “/AffiliateWiz”

 -pe indicates that the application is built as IIS based site. The second argument is the name of configuration section needs to be encrypted. Third argument “-app” indicates virtual directory and last argument is the name of virtual directory where application is deployed which in this case is AffiliateWiz.   

   If everything goes well you will receive a message “Encrypting configuration section…Succeeded!”

  Open your web.config file and you can see that connection string is encrypted,

   1: <connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
   2:   <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
   3:    xmlns="http://www.w3.org/2001/04/xmlenc#">
   4:    <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
   5:    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
   6:     <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
   7:      <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
   8:      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
   9:       <KeyName>Rsa Key</KeyName>
  10:      </KeyInfo>
  11:      <CipherData>
  12:       <CipherValue>Ik+l105qm6WIIQgS9LsnF8RRxQtj2ChEwq7DbHapb440GynFEoGF6Y3EM3Iw/lyDV8.......kLFC0=</CipherValue>
  13:      </CipherData>
  14:     </EncryptedKey>
  15:    </KeyInfo>
  16:    <CipherData>
  17:     <CipherValue>JsLrQ5S8Pq3U72nQzmSl/XlLX72GM0O3EbPLaHRNvjTDgG9seDflGMjTfO10M1s.......</CipherValue>
  18:    </CipherData>
  19:   </EncryptedData>
  20:  </connectionStrings>

 

Now should you need to decrypt the configuration section in web.config file use following command,

For File System Application,

aspnet_regiis.exe -pdf “connectionStrings” C:\inetpub\wwwroot\affiliatewiz

For IIS based Application

aspnet_regiis.exe -pd “connectionStrings” -app “/affiliatewiz”

 

COPYRIGHT 2000-2015 ADCOMPLETE.COM, LLC
PRIVACY POLICY
HOME  |  CONTACT US  |  SUPPORT  |  PURCHASE  |  AFFILIATE PROGRAM  |  AFFILIATE MARKETING RESOURCES