views:

81

answers:

2

I am developing a .NET (2.0) WinForms utility that connects to a SQL Server 2005 database. I have found reference material, such as Avoiding Plaintext Passwords for handling the actual encryption of the connection string data. I now need to implement the encryption during the installation process so that an administrator can install the utility on a user's desktop, but not provide the user with the database connection information.

The sample code all seems geared toward performing the encrypting within the primary application. So the app would need to be executed once for the encryption to take place. If the application is installed but not executed, the configuration information would be in plain text in the configuration file.

Can anyone provide information showing how the encryption can be performed from the setup app. Other approaches to the problem are welcome as well (however, due to business requirements, I am not in a position to require Windows authentication for the database connection - I am limited to SQL Server authentication).

Edit: I may have been overly brief with my description. We have already performed a risk assessment and determined that using the built-in .NET framework functionality for encrypting the connection information provides sufficient security for the application.

We understand that a truly determined individual could eventually obtain the connection information, and we readily accept that risk. The purpose of encrypting the connection data is to simply raise the bar of effort and to help "keep honest people honest".

Having already worked out the means of performing the encryption, I am now trying to work out a method of performing the encryption from within the installation process. Any help along those lines woul be appreciated. Thanks!

+2  A: 

The main problem with encrypted configuration is protecting the key used to decrypt the configuration settings.

With a server application, you can do this by restricting access to the server. A client WinForms app will need to have access to the key while running as the current user, therefore the user will be able to find the key if he is smart enough.

If you can't use Windows authentication for the database connection, or use an n-tier architecture with the data access code on a server, you won't be secure.

Joe
As pointed out in the link I provided, .NET provides me with the means of encrypting the data in the config file. I just need a means of performing that encryption during installation of the app. Managing the encryption key is handled by the .NET framework. Thanks for the response though!
JeremyDWill
+1  A: 

What about having the installer run a postscript process during the setup?

That way it will be run during instalation and therefore under administration surveilance and the code for the encritpion will be whatever you like it to be.

Jorge Córdoba
This is the route I will probably go. I can add the enryption code in the main app, then have the installer launch the app with a command-line parameter indicating that encryption should occur. Thanks.
JeremyDWill