Re: Using encrypted dB connection string
From: Rick Spiewak (rickspiewak_at_mindspring.com)
Date: 05/22/04
- Next message: Rick Spiewak: "Re: Set Column Width in DataList"
- Previous message: DalePres: "Re: Advice on asp.net for comercial programmer"
- In reply to: Alek Davis: "Re: Using encrypted dB connection string"
- Next in thread: johndoe_at_driver.net: "Re: Using encrypted dB connection string"
- Reply: johndoe_at_driver.net: "Re: Using encrypted dB connection string"
- Reply: Alek Davis: "Re: Using encrypted dB connection string"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 21 May 2004 23:25:02 -0400
See the following article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT07.asp.
This describes the use of the DPAPI library and the machine key (or user
key, but for your purpose stick to the machine key) to encrypt and decrypt
things like the connection string. Because the key is known by the DPAPI
library, you don't need to provide it (or even know it).
You can pretty easily follow the article, and compile the library. I've also
written a VB.NET "wrapper" which simplifies the use of this library (but
still requires it) if you're interested. You will then need to use an
ASP.NET page (I've also written that if you like) which you will temporarily
install on your web site - the encryption technique used here relies on the
machine key for the actual machine on which you are running, so you can't do
this with a Windows app, although you could also do it with a web service.
You can then encrypt the connection string, and put it into the config file,
and then decrypt it at runtime. Then, if you're using an ASP.NET page which
knows how to encrypt/decrypt using DPAPI, you should remove it from your web
site since anyone who could find their way to it could use the decryption
facility!!
The only caveat is that if your hosting service replaces the machine you're
running on and doesn't maintain the machine key, you'll have to re-do the
encryption steps above.
"Alek Davis" <alek_xDOTx_davis_xATx_intel_xDOTx_com> wrote in message
news:ei79Ws3PEHA.832@TK2MSFTNGP09.phx.gbl...
> Charlie,
>
> If you use passwords for user authentication only, do not use encryption,
> use hashing (with salt) instead. If you need to use encryption, in your
> particular scenario (Web hosting environment to which you have limited
> access), the best you can do is use a tool like CipherLite.NET (see
> http://www.obviex.com/cipherlite/). You will need to embed the passphrase
> (to generate encryption key) in your code, so if a hacker gets hold of
your
> assembly, this passphrase can be easily retrieved unless you obfuscate the
> assembly using a good commercial obfuscator (and even this will not
> guarantee security). Unfortunately, you don't have many options. If you
find
> a better approach, please post it here; there may be other readers in the
> same situation.
>
> Alek
>
> "Charlie@CBFC" <charle1@comcast.net> wrote in message
> news:O80gzh3PEHA.3232@TK2MSFTNGP11.phx.gbl...
> > Hi:
> >
> > My host will not allow me use a trusted connection or make registry
> setting,
> > so I'm stuck trying find a way to hide connection string which will be
> > stored in web.config file. If I encrypt string externally, can it be
used
> > in it's encrypted form to connect to SQL Server? If I decrypt back to
> > string for use in connection string during runtime, I have to supply a
> key.
> > If I do that, hacker could use key to break encryption. How do I handle
> > this? I'll be storing passwords in database and don't want a hacker to
> get
> > in.
> >
> > Thanks,
> > Charlie
> >
> >
> >
>
>
- Next message: Rick Spiewak: "Re: Set Column Width in DataList"
- Previous message: DalePres: "Re: Advice on asp.net for comercial programmer"
- In reply to: Alek Davis: "Re: Using encrypted dB connection string"
- Next in thread: johndoe_at_driver.net: "Re: Using encrypted dB connection string"
- Reply: johndoe_at_driver.net: "Re: Using encrypted dB connection string"
- Reply: Alek Davis: "Re: Using encrypted dB connection string"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|