Keyfile distribution with ClickOnce

Topics: Cryptography Application Block
Jan 16, 2008 at 3:11 PM
Here's my scenario...

I'm developing a SmartClient application that is going to be deployed to many users in the organisation using ClickOnce, the application has a database connection string that needs to be encrypted for the purpose of preventing the end user easily knowing the db password.

I'm happy with the security level if we encrypt the app.config stored connection string, and distribute the key to the clients.

I've come down to two possible solutions, but would like some advice as i'm quite new to this...

1. Use the Rijndael encryption method with the Cryptography application block, encrypt the connection string during development. Export the keyfile and secure it with a password, and package it in the ClickOnce installation. The when the Client runs the application I can restore the encryption key, update the configuration file with the path of the keyfile and decrypt the connection string.

2. Use RSA encryption, export the RSA key container and distribute the xml file with the clickonce. Once on the Client, the application can import the key container, or alternatively we can distribute the key container using a Network install procedure (SMS for example)

What I like about solution 1 is that when the key sites on the webserver in the ClickOnce package, it is password protected, as far as I know the RSA xml key that gets exported isn't. But when I restore the Rijndael key file to the Clients machine, how can I secure it? With the RSA key container it gets protected with ACL rights.

Is there a way I can programatically restore the Rijndael key and secure access to it in the same way that RSA keys are imported using aspnet_regiis?

Is there a way I can password protect the exported RSA key xml file?