473,791 Members | 2,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Web.config

Should the web.config file be included in my deployment, IE physically
located in the web app's virtual directory on a release? It makes me
nervous having my DB conn string, etc in a ASCII file so available. I am
hoping the answer is "it gets compiled, and is placed in the
\bin\myproject. dll file"

Chris
Nov 17 '05 #1
3 4199

The web.config file is human readable, and not encoded - meaning, yes, if
you are concerned with security, you should encrypt (or store elsewhere)
sensitive data like connection strings. The web.config file is a means of
altering the state of an application while it's running, without shutting
down services.

One solution is to encrypt the connection string (or any sensitive data)
using the available crypto classes in the security assembly. Then you can
decrypt the connection string when it's needed by the application. I'll
paste some sample code for this below.
Charlie Nilsson [msft]
Visual Studio Update
'############## ############### ############### ############### #######
' Sample encryption code in VB
'############## ############### ############### ############### #######
Imports System
Imports System.IO
Imports System.Security .Cryptography
Imports System.Text

Public Class MyCryptoClass

'private key - enter random numbers here
Private Shared key() As Byte = {12, 52, 53, 124, 33, 36, 77, 48, 29, 50,
111, 112, 213, 14, 135, 116, 167, 198, 109, 200, 211, 29, 33, 35}
'init vector
Private Shared iv() As Byte = {12, 125, 37, 140, 65, 56, 76, 18, 99, 107,
122, 123, 153, 114, 159, 196, 179, 198, 192, 220, 212, 123, 33, 54}

'############## ############### ############### ############### #######
' Encrypt
' - Encrypts a plaintext string
'############## ############### ############### ############### #######
Public Shared Function Encrypt(ByVal plainText As String) As String
Dim cryptoProvider As TripleDESCrypto ServiceProvider = New
TripleDESCrypto ServiceProvider
Dim ms As MemoryStream = New MemoryStream
Dim cs As CryptoStream = New CryptoStream(ms ,
cryptoProvider. CreateEncryptor (key, iv), CryptoStreamMod e.Write)
Dim sw As StreamWriter = New StreamWriter(cs )
sw.Write(plainT ext)
sw.Flush()
cs.FlushFinalBl ock()
ms.Flush()
'convert back to a string
Return Convert.ToBase6 4String(ms.GetB uffer(), 0, ms.Length)
End Function

'############## ############### ############### ############### #######
' Decrypt
' - Decrypts a plaintext string
'############## ############### ############### ############### #######
Public Shared Function Decrypt(ByVal encodedText As String) As String
Dim cryptoProvider As TripleDESCrypto ServiceProvider = New
TripleDESCrypto ServiceProvider
'convert from string to byte array
Dim buffer As Byte() = Convert.FromBas e64String(encod edText)
Dim ms As MemoryStream = New MemoryStream(bu ffer)
Dim cs As CryptoStream = New CryptoStream(ms ,
cryptoProvider. CreateDecryptor (key, iv), CryptoStreamMod e.Read)
Dim sr As StreamReader = New StreamReader(cs )
Return sr.ReadToEnd()
End Function

End Class








--

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm






Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
--------------------
Reply-To: "Chris Fink" <ch***@chrisfin k.com>
From: "Chris Fink" <ch***@chrisfin k.com>
Subject: Web.config
Date: Fri, 11 Jul 2003 11:55:43 -0400
Lines: 9
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#w************ **@TK2MSFTNGP10 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
NNTP-Posting-Host: 130.decisionone .com 192.204.130.200
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1585 68
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet

Should the web.config file be included in my deployment, IE physically
located in the web app's virtual directory on a release? It makes me
nervous having my DB conn string, etc in a ASCII file so available. I am
hoping the answer is "it gets compiled, and is placed in the
\bin\myproject. dll file"

Chris


Nov 17 '05 #2
Or you can use a tool like this one (or roll out your own as Charlie
suggested): http://www.obviex.com/cipherlite/. However, be aware of the risk
of embedding the key in your application source code.

Alek

"Charlie Nilsson [MSFT]" <Ch************ ********@hotmai l.com> wrote in
message news:Sy******** ******@cpmsftng xa06.phx.gbl...

The web.config file is human readable, and not encoded - meaning, yes, if
you are concerned with security, you should encrypt (or store elsewhere)
sensitive data like connection strings. The web.config file is a means of
altering the state of an application while it's running, without shutting
down services.

One solution is to encrypt the connection string (or any sensitive data)
using the available crypto classes in the security assembly. Then you can
decrypt the connection string when it's needed by the application. I'll
paste some sample code for this below.
Charlie Nilsson [msft]
Visual Studio Update
'############## ############### ############### ############### #######
' Sample encryption code in VB
'############## ############### ############### ############### #######
Imports System
Imports System.IO
Imports System.Security .Cryptography
Imports System.Text

Public Class MyCryptoClass

'private key - enter random numbers here
Private Shared key() As Byte = {12, 52, 53, 124, 33, 36, 77, 48, 29, 50,
111, 112, 213, 14, 135, 116, 167, 198, 109, 200, 211, 29, 33, 35}
'init vector
Private Shared iv() As Byte = {12, 125, 37, 140, 65, 56, 76, 18, 99, 107,
122, 123, 153, 114, 159, 196, 179, 198, 192, 220, 212, 123, 33, 54}

'############## ############### ############### ############### #######
' Encrypt
' - Encrypts a plaintext string
'############## ############### ############### ############### #######
Public Shared Function Encrypt(ByVal plainText As String) As String
Dim cryptoProvider As TripleDESCrypto ServiceProvider = New
TripleDESCrypto ServiceProvider
Dim ms As MemoryStream = New MemoryStream
Dim cs As CryptoStream = New CryptoStream(ms ,
cryptoProvider. CreateEncryptor (key, iv), CryptoStreamMod e.Write)
Dim sw As StreamWriter = New StreamWriter(cs )
sw.Write(plainT ext)
sw.Flush()
cs.FlushFinalBl ock()
ms.Flush()
'convert back to a string
Return Convert.ToBase6 4String(ms.GetB uffer(), 0, ms.Length)
End Function

'############## ############### ############### ############### #######
' Decrypt
' - Decrypts a plaintext string
'############## ############### ############### ############### #######
Public Shared Function Decrypt(ByVal encodedText As String) As String
Dim cryptoProvider As TripleDESCrypto ServiceProvider = New
TripleDESCrypto ServiceProvider
'convert from string to byte array
Dim buffer As Byte() = Convert.FromBas e64String(encod edText)
Dim ms As MemoryStream = New MemoryStream(bu ffer)
Dim cs As CryptoStream = New CryptoStream(ms ,
cryptoProvider. CreateDecryptor (key, iv), CryptoStreamMod e.Read)
Dim sr As StreamReader = New StreamReader(cs )
Return sr.ReadToEnd()
End Function

End Class








--

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm






Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
--------------------
Reply-To: "Chris Fink" <ch***@chrisfin k.com>
From: "Chris Fink" <ch***@chrisfin k.com>
Subject: Web.config
Date: Fri, 11 Jul 2003 11:55:43 -0400
Lines: 9
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#w************ **@TK2MSFTNGP10 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
NNTP-Posting-Host: 130.decisionone .com 192.204.130.200
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1585 68 X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet

Should the web.config file be included in my deployment, IE physically
located in the web app's virtual directory on a release? It makes me
nervous having my DB conn string, etc in a ASCII file so available. I am
hoping the answer is "it gets compiled, and is placed in the
\bin\myproject. dll file"

Chris

Nov 17 '05 #3
It must be included, in it's raw form.

However, IIS won't allow browsing the file- it's specifically DISALLOWED -
so no exposure there.
As far as local access, set Windows security for only the internal IIS user,
developers group etc to have access, and you should be OK.

"Chris Fink" <ch***@chrisfin k.com> wrote in message
news:#w******** ******@TK2MSFTN GP10.phx.gbl...
Should the web.config file be included in my deployment, IE physically
located in the web app's virtual directory on a release? It makes me
nervous having my DB conn string, etc in a ASCII file so available. I am
hoping the answer is "it gets compiled, and is placed in the
\bin\myproject. dll file"

Chris

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3021
by: Maxim Khesin | last post by:
I want to have a config file with my python proggie, satisfying the following requirements: 1) support key->(value, default) 2) simple and intuitive to read and edit 3) easyly readable into a python datastructure (a dictionary?) 4) not requiring any heavy libraries needed (I am distributing my proggie as a py2exe executable and do not want to bloat the size) can you guys suggest some format for this? thanks, max
4
3830
by: Fuzzyman | last post by:
There have been a couple of config file 'systems' announced recently, that focus on building more powerful and complex configuration files. ConfigObj is a module to enable you to much more *simply* access config files. This is version 3, which is a big overhaul. It extends ConfigObj to reading config files with sections and various other simplifications. I find ConfigObj extremely easy to use and use it for reading config files and data...
3
3820
by: Richard Lewis Haggard | last post by:
I have a test application that is calling an assembly that reads some strings out of a config file. Normally, this assembly supports a web application and the information can be read just fine. Then I created a C# test application and ran the function. The function fails because the configuration read is failing to find a key. I created an application config and copied the keys over to the app config file but the app is still failing to...
13
507
by: Khodr | last post by:
Hello, I am using VS.NET 2003 and vb. I build my application MyApp and it generates MyApp.exe.config. So now MyApp.exe reads parameters from MyApp.exe.config. Great and no problem! I need to run the same program but with different configuration data. So I made a copy of MyApp.exe and MyApp.exe.config to put them in another folder and renamed the copy to MyApp2.exe and MyApp2.exe.config respectively. I ran it but it did not read from...
20
2626
by: tomerfiliba | last post by:
hey i've been seeing lots of config-file-readers for python. be it ConfigObj (http://www.voidspace.org.uk/python/configobj.html) or the like. seems like a trend to me. i came to this conclusion a long time ago: YOU DON'T NEED CONFIG FILES FOR PYTHON. why re-invent stuff and parse text by yourself, why the interpreter can do it for you? and anyway, i find this a very ugly format:...
11
3451
by: TARUN | last post by:
Hello All I need to ask about the configuration file in .NET, There are Two config File 1. Web Config 2. Machine config I understand the the usage of Web config , but not able to understand the usage of Machine config. I read in the article that you can also write your database connection string in Machine Config
12
13439
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD file was built by draging tables from the Data Sources pane. Auto-generated code created the files associated wtih the XSD file (xss,
5
7866
by: mmcd79 | last post by:
I built a VB.net application that makes use of a machine level DB connection string setting, and a user level starting location setting. The machine level setting and the default user based setting is of course stored in the app.exe.config file located in the same directory as the exe. Upon closing the form, I save the user setting which then creates a user.config file in the appdata directory in my profile. This is all well and good....
10
2062
by: eagle | last post by:
I have a web.config in my application that contains the connection strings to all my datasources. I want to move these connection strings to another web config up the folder hierarchy so that all my apps can use the same connection strings. That is supposed to be how it's done, no? Instead of the web.config being in c:\inetpub\wwwroot\myApp\web.config, I have it in c:\inetpub\wwwroot\web.config. However, I get an "Object reference not...
5
2863
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a app that uses several membership/role providers. I can list these Providers with the code: Dim rootWebConfig1 As Configuration rootWebConfig1 = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath) Dim section As New MembershipSection section = rootWebConfig1.GetSection("system.web/membership")
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.