encrypting connection strings for network installed application
- From: "Chris Dunaway" <dunawayc@xxxxxxxxx>
- Date: 10 Aug 2006 08:38:53 -0700
I have an application which is installed on a network share to be run
from one or more workstations. I have granted trust to the
applications on the workstations and the appropriate permissions on the
shared folder and the user's can execute the app with no problem.
I do have a problem, however, after the application starts. In the
application's .config file, the connectionStrings section of the file
is encrypted upon first run of the app (this is temporary). When
encrypted, the connectionStrings section can only be successfully
decrypted on the machine that first encrypted it. Other workstations
will not be able to run because they cannot decrypt the
connectionStrings section.
Here is the code used to encrypt the connectionStrings section of the
..config file:
//Encrypts the connectionStrings section of the .config file if
not already
static void ConfigEncryption()
{
string exeName = Assembly.GetExecutingAssembly().Location;
// Open the configuration file and retrieve
// the connectionStrings section.
Configuration config =
ConfigurationManager.OpenExeConfiguration(exeName);
ConnectionStringsSection section =
config.GetSection("connectionStrings") as ConnectionStringsSection;
//If the section is not already encrypted
if (!section.SectionInformation.IsProtected)
{
// Encrypt the section.
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
// Save the current configuration if we encrypted it
config.Save();
}
}
I believe my problem stems from the fact that when encrypted, the
encryption keys used are based on the machine that did the encrypting.
Other machines, because they do not have the keys, cannot decrypt the
connectionString. Somehow, I need to let the other workstations know
how to decrypt the connectionString section of the .config file.
Can anyone suggest any means to do what I want? What I want is the
following:
1. Be able to run the app from a network share from one or more
workstations.
2. Be able to encrypt the connectionStrings section of the .config
file.
Thanks for any information,
Chris
.
- Follow-Ups:
- Re: encrypting connection strings for network installed application
- From: William Stacey [MVP]
- Re: encrypting connection strings for network installed application
- From: Marc Gravell
- Re: encrypting connection strings for network installed application
- Prev by Date: Re: download file on click - permissions getting in the way
- Next by Date: Re: ListView in a UserControl
- Previous by thread: Re: XML Namespace & Serialization
- Next by thread: Re: encrypting connection strings for network installed application
- Index(es):
Relevant Pages
|