views:

403

answers:

3

I'm using Visual Studio 2008 Pro to create a VB Winform App. I have some custom configuration settings as well as a MS SQL connection string in my app.config file.

  1. What is the best method to insure that no one can read these settings in the app.config?
  2. Are there any other area's that would have the connection string in plain text that I might want to consider securing as well?

Thank you!

+5  A: 

One method to protect your app.config is to encrypt it from prying eyes. Check out this article on Encrypting Passwords in a .NET app.config File or this one on Encrypting the app.config File for Windows Forms Applications.

In response to part two of your question: memory! Unencrypted data can hang around in unprotected memory until the Garbage Collector picks it up. So for that reason you'll want to look at using the SecureString class whenever you deal with passwords, connection strings and the like. The first article touches on this point.

Gavin Miller
Yeap- that's the technique I use too. I have some more links in a question I answered previously- http://stackoverflow.com/questions/1075245/encrypting-web-config/1075312#1075312
RichardOD
Thank you for your assistance ...That points me in the right direction. In addition, the info on the SecureString class will be a great help as well.Thanks again!
dc
+1  A: 

Check this article out

http://guy.dotnet-expertise.com/PermaLink,guid,b3850894-3a8e-4b0a-aa52-5fa1d1216377.aspx

Edit

It may not be as easy as everyone else is saying. I'm not sure if things have changed, but this article outlines challenges actually faced by someone trying this, and the final solution, which worked.

David Stratton
Thanks for the link. Reading that article seems to make me think that there really is no good way (still) to secure an app.
dc
A: 

There's a post explaining how to encrypt settings in app.config file.

Darin Dimitrov
Thank you for the link ...I always like code examples. I never seem to get it right by just reading about it.
dc