Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Encrypting web.config files using a NON IIS web server
pandiani
#1 Posted : Wednesday, April 11, 2007 1:56:09 PM(UTC)
Groups: Member
Joined: 4/11/2007(UTC)
Posts: 2
Location: San Diego

Hello there,
My windows application has a browser component to navigate local sites.
The app is written in C# and VS 2005. It works perfectly under IIS and I tried embedding Cassini directly. This second solution allows me to navigate the site but when I need to encrypt the web.config file ....i get the problems

So before I try embeding UltiDev into my application I need to know if I can encrypt web.config files
using one of the 2 following techniques:
1)
Configuration config = WebConfigurationManager.OpenWebConfiguration("/MyVirtualSite");
ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection;
if (section.SectionInformation.IsProtected == false)
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
config.Save();


2) Running a command with aspnet_regiis
string param = "-pe \"connectionStrings\" -app \"/MyVirtualSite\" -prov \"DataProtectionConfigurationProvider\"";
Process myProcess = new Process();
object o = new object();
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.FileName = "aspnet_regiis";
myProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(o.GetType().Assembly.Location);
myProcess.StartInfo.Arguments = param;
myProcess.Start();
myProcess.WaitForExit();
myProcess.Close();


The issue seems to be that both "WebConfigurationManager.OpenWebConfiguration" and "aspnet_regiis" takes the parameter VirtualDirectory from IIS in order to get the PhysicalPath of the web.config. In my case, IIS will be disabled (that's the reason of using embeded solution) so both code fail !!!

QUESTON:
Is there a way using UltiDev that allows me to encrypt the web.config files located in a folder of my knowledge?

Thanks,
Filippo




Ultidev Team
#2 Posted : Wednesday, April 11, 2007 4:15:07 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Filippo,

we are pretty sure that option 2 won't work because it is IIS-specific, but option 1 might work. We will need a little bit of time to verify this. Give us a day or so to find out. We will post the results as soon as the verdict is in. If you happen to have the answer sooner, please let everyone know.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Ultidev Team
#3 Posted : Thursday, April 12, 2007 12:53:07 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Filippo,

We are still working on this.
We'll keep you posted.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Ultidev Team
#4 Posted : Friday, April 13, 2007 5:29:18 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Filippo,

Add following to your Globala.sax. It will work in Cassini but may or may not not work in IIS depending on the IIS/appPool user account access rights.
Code:
void Application_Start(object sender, EventArgs e)
{
Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection;
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
config.Save();
}
}


Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Rss Feed  Atom Feed
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.