Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Connection String Encryption / Protection

Tags:

asp.net

What is best practice for protection/encryption of connection strings in ASP.NET rather than just storing as plain text in Web.Config

like image 345
AJM Avatar asked Apr 17 '09 14:04

AJM


3 Answers

Take a look at Programmatically encrypting a config-file in .NET, it seems to cover this ground.

like image 91
Steve Avatar answered Oct 08 '22 00:10

Steve


You can set this section to be encrypted.

However, that default encryption has pitfalls pointed out by others. You can also set your connection strings section to point to an external file, and that external file will work in concert with encryption. That should solve most concerns, because the sysadmin can set up encryption there without breaking anything else in the developer's web.config and a devloper can deploy changes to the config without undoing the sysadmin's encryption.

like image 20
Joel Coehoorn Avatar answered Oct 08 '22 01:10

Joel Coehoorn


Web.Config has built in support for encrypting connection strings (and other data), but this does have some overhead because the encryption is tied to the server, so the encryption must be set up by a server admin and not the developer.

you could also encrypt manually, with the encryption routine in your source.

Why are you encrypting? Who are you protecting from? Hackers getting access to the web config? Developers that shouldnt know the prod connection string? The reasons behind the encryption will change the solution somewhat.

like image 23
Jason Coyne Avatar answered Oct 08 '22 00:10

Jason Coyne