We have a C# application that is used to remotely manage our web applications. One of its functions is create and populate new virtual directories (Applications in IIS 7) on our web servers. The application was written to work with IIS 6 serveral years
ago. We have now moved to all our systems to IIS 7 (Windows 2008). We want to updated this application to use the Microsoft.Web.Administration namespace classes rather than using the System.DirectoryServices classes that are currently used. This will allow
us to leave the IIS 6 Compatibility components out of new Windows installations.
I had no problems getting the Microsoft.Web.Administration classes to create new applications on our IIS 7 machines, but I can not figure out how to set the SSL setting on an application or for that matter on a web site using these classes. Any idea how
it is done? We run a mix of web applications on a web site so that one application will require SSL and another application on the site will not.
Depending on which settings you want to enable, enabling SSL you basically have to add a binding, the Site has a Bindings collection which has an overload that receives the certificateHash and the certificateStore, something like:
ServerManager serverManager = new ServerManager();
serverManager.Sites["Default Web Site"].Bindings.Add("*:443:", certificateHash, "My");
You can also just set the CertificateHash property in an existing Binding.
mikesm
2 Posts
Setting SSL Settings with Microsoft.Web.Administration
Nov 17, 2009 06:06 PM|LINK
We have a C# application that is used to remotely manage our web applications. One of its functions is create and populate new virtual directories (Applications in IIS 7) on our web servers. The application was written to work with IIS 6 serveral years ago. We have now moved to all our systems to IIS 7 (Windows 2008). We want to updated this application to use the Microsoft.Web.Administration namespace classes rather than using the System.DirectoryServices classes that are currently used. This will allow us to leave the IIS 6 Compatibility components out of new Windows installations.
I had no problems getting the Microsoft.Web.Administration classes to create new applications on our IIS 7 machines, but I can not figure out how to set the SSL setting on an application or for that matter on a web site using these classes. Any idea how it is done? We run a mix of web applications on a web site so that one application will require SSL and another application on the site will not.
IIS7 remote Administration issue
steve schofi...
5682 Posts
MVP
Moderator
Re: Setting SSL Settings with Microsoft.Web.Administration
Nov 17, 2009 11:05 PM|LINK
Steve Schofield
Windows Server MVP - IIS
http://iislogs.com/steveschofield
http://www.IISLogs.com
Log archival solution
Install, Configure, Forget
CarlosAg
745 Posts
Microsoft
Moderator
Re: Setting SSL Settings with Microsoft.Web.Administration
Nov 18, 2009 05:20 AM|LINK
Depending on which settings you want to enable, enabling SSL you basically have to add a binding, the Site has a Bindings collection which has an overload that receives the certificateHash and the certificateStore, something like:
ServerManager serverManager = new ServerManager();
serverManager.Sites["Default Web Site"].Bindings.Add("*:443:", certificateHash, "My");
You can also just set the CertificateHash property in an existing Binding.
To set the sslFlags you will need to set the system.webServer/security/access section, see: http://www.iis.net/ConfigReference/system.webServer%2fsecurity%2faccess
mikesm
2 Posts
Re: Setting SSL Settings with Microsoft.Web.Administration
Nov 18, 2009 01:13 PM|LINK
Thanks! The referenced Access Security article was exactly what I was looking for. Now I can set the sslFlags.