powlette
powlette

Reputation: 1800

Where/how can I store SQL Server connection string so that its securely available to remote apps?

We have .net apps running on many machines now. The db connection string is stored it a settings XML file on each. Each application starts up and as a first step, loads this string from its settings file. It works fine, but if we ever had to change our login info, it would be a nightmare to find all the places we've stored it over the years. Further, with virtual machines, we're adding new machines all the time and it would be ideal to simply deploy the exes/dlls and have the app get the connection string automatically and securely.

I considered encrypting the string and putting it on our web server so the remote apps can fetch it via http and dns name and decrypt it but that's rather simplistic and since security is so important for this piece of info, I need to be very careful.

So the question is, how do you securely decimenate connection string to remote apps so upon startup they'll know to reach the db? Once they can do that, they can fetch addition settings from a configuration table in the database.

Upvotes: 4

Views: 579

Answers (1)

usr
usr

Reputation: 171206

What parts of your system do you trust? You have to trust the clients 100% because once they have the connection string (which they have to have) they can to anything to the DB that they want. You also have to trust the servers.

So it seems you are trusting everyone. That makes securing the system easy: It is already secure, no matter how you distribute the connection string.

I've seen a lot of superstitiousness when it comes to saving and distributing passwords and connection strings. Many people are uncomfortable having them sent and stored in the clear. That is irrational because the clients have do have it in the clear eventually. It is impossible to prevent that.

So my advice is: Make a simple webservice that provides the following API:

string GetConfigSetting(string name)

Clients can ask that service for the connection string. This service is so simple that its interface will probably never change.

There is little point bothering with encryption in this case. A client application can easily be decompiled to access any decryption routine. Also, the client has to decrypt the secret eventually. At this point an attacker controlling the client machine can read the secret in the clear.

Upvotes: 3

Related Questions