Programmatically add binding to IIS 8 with SNI

I am trying to create bindings for IIS 8 that have the SNI flag set (server name) using the Microsoft.Web.Administration library (.NET Framework).

This is necessary for me because I want to get multiple SSL bindings for the same website in IIS using only one IP address. This is one of the major new features in IIS 8.

I studied the Binding class, and I cannot find any flag or parameter to indicate it.

Is this possible with the current version of Microsoft.Web.Administration v 7.0.0.0? Do I need a new version that I have not found?

I know that version 7.9.0.0 is for IIS express only, and this is not my script, so I did not view it.

+4
source share
2 answers

I managed to do this using Microsoft.Web.Administrationfrom a folder %windir%\system32\inetsrv\, but only on Windows 8 / Windows 2012 with IIS 8 .

These libraries had an option SslFlagsin the function Addfor the class BindingCollection. There is no documentation from Microsoft, but for this new overload, or at least I did not find it.

SslFlags.Sni is available for use in this and creates a binding with SNI verification.

+8
source

Is this possible with current Microsoft.Web.Administration v 7.0.0.0?

Indeed, manually adding the attribute sslFlagsto <binding>node:

Binding mySslBinding;
bool enableSni;

using (var serverManager = new ServerManager())
{
    ... create or get value of mySslBinding...

    mySslBinding.SetAttributeValue("sslFlags", Convert.ToInt32(enableSni));

    serverManager.CommitChanges();
}

, IIS 8.0 CommitChanges() , sslFlags .

+3

All Articles