Jump to content

Encrypting the DB Connection String in the Web.config file


Recommended Posts

Whilst it's not entirely necessary to encrypt the database connection strings within the web.config file, it is recommended so the SQL Account credentials used to access the Passwordstate database is encrypted and unreadable from anyone who can read the file system on your web server.

To encrypt the database connections string, please follow these instructions:

Encrypt Connection String

 

  • Open a command prompt and change to the v4.0.30319 .Net Framework folder (normally found under C:\Windows\Microsoft.NET\Framework\v4.0.30319)
  • Type the following:
    aspnet_regiis.exe -pef "connectionStrings" "c:\inetpub\passwordstate" (change the path if you've installed Passwordstate to a different location)

 

Decrypt Connection String

 

  • Open a command prompt and change to the v4.0.30319 .Net Framework folder folder (normally found under C:\Windows\Microsoft.NET\Framework\v4.0.30319)
  • Type the following:
    aspnet_regiis.exe -pdf "connectionStrings" "c:\inetpub\passwordstate" (change the path if you've installed Passwordstate to a different location)

 

Regards

Click Studios

Link to post
Share on other sites
  • 4 years later...

Just a note, if you are running the PasswordState service under a different account, you have to explicitly give it permissions to read the encryption keys, if you encrypt the database connection string, by using this command:

 

aspnet_regiis -pa "NetFrameworkConfigurationKey" "Domain\Username of service account"
Link to post
Share on other sites

Hi abj,

 

Thanks for mentioning this - we weren't aware of it.

 

In version 7 there is no need to run the Windows Service under the identity of an account any more - just thought we would mention it in case you weren't aware.

 

Regards

Click Studios

Link to post
Share on other sites
  • 3 years later...

Don't work for me (Dr. Google could't help me either)

Error Message is "Illegal characters in path"

 

 

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis.exe -pef "connectionStrings" "c:\inetpub\Passwordstate\"
Microsoft (R) ASP.NET RegIIS, Version 4.0.30319.0
Das Verwaltungsprogramm zum Installieren und Deinstallieren von ASP.NET auf dem lokalen Computer.
Copyright (C) Microsoft Corporation.  Alle Rechte vorbehalten.
Der Konfigurationsabschnitt wird verschlüsselt...
Illegales Zeichen im Pfad.
Fehler

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...