Install SSL certificate programmatically using Microsoft.Web.Administration

前端 未结 7 1691
执念已碎
执念已碎 2020-12-28 20:11

So the Microsoft.Web.Administration API is very easy to use to create HTTP and HTTPS bindings for sites:

using (ServerManager manager = new          


        
相关标签:
7条回答
  • 2020-12-28 20:42

    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();
    
    0 讨论(0)
提交回复
热议问题