DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 18 Jul 2007 05:04:02 -0700,    posted on: microsoft.public.dotnet.framework.aspnet.security        back       

Thread Index
  1    DavidE


Encrypt and decrypt connectionstrings in web.config   
Hi,

I use the code below to encypt and decrypt connectionstrings in the 
web.config files.
It works good but I don't understand somthing about the decryption. An 
hacker that gain the web.config file with the encrypted data, can copy it to 
a new web site that he created and use this line of code  
section.SectionInformation.UnprotectSection() and so get the connectionstring 
in plain text .I tried it. I copyed the web config to a new web site and then 
used this line of code and I got the original connectionstring. !!!!
Am I right ? If I am, It is not a security solution.


public void EncryptConnString()
    {
        Configuration config = 
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
        ConfigurationSection section = config.GetSection("connectionStrings");
        if (!section.SectionInformation.IsProtected)
        {
            
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
            config.Save();
        }
    }


public void DecryptConnString()
    {
        Configuration config = 
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
        ConfigurationSection section = config.GetSection("connectionStrings");
        if (section.SectionInformation.IsProtected)
        {
            section.SectionInformation.UnprotectSection();
            config.Save();
        }
    } 

 
Thanks,

 David
Date:Wed, 18 Jul 2007 05:04:02 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us