I'm using Microsoft.Web.Administration
(inside a Wix CustomAction) to configure Server Name Indication and bind to an existing server certificate on a IIS 8.5 site.
Turns out, setting SNI takes off the certificate binding. The following code will make things clearer:
using Microsoft.Web.Administration;
var binding = site.Bindings.FirstOrDefault(x => x.IsIPPortHostBinding && x.Host == sitename);
binding.CertificateHash = certificate.GetCertHash();
binding.CertificateStoreName = store.Name;
// this statement is causing the certificate info to get messed up.
binding["sslFlags"] = 1; // or binding.SetAttributeValue("sslFlags", 1);
Results:
With binding["sslFlags"] = 1;
Without binding["sslFlags"] = 1;
Is this a bug or am I missing something? How can get both SNI and Certificate binding to stick?