So the Microsoft.Web.Administration API is very easy to use to create HTTP and HTTPS bindings for sites:
using (ServerManager manager = new
The namespace doesn't contain an API for this, so you have to use its ConfigurationMethod
to invoke an extension to the Win API that performs this function. Something like:
string certificateHash = <hash>
string certificateStore = <storename> #my, localmachine, etc
ConfigurationMethod method = binding.Methods["AddSslCertificate"];
ConfigurationMethodInstance mi = method.CreateInstance();
mi.Input.SetAttributeValue("certificateHash", certificateHash);
mi.Input.SetAttributeValue("certificateStoreName", certificateStore);
mi.Execute();