Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C自动将SSL证书安装到IIS 6站点#_C#_Ssl_Iis 6_Directoryservices - Fatal编程技术网

C# 使用C自动将SSL证书安装到IIS 6站点#

C# 使用C自动将SSL证书安装到IIS 6站点#,c#,ssl,iis-6,directoryservices,C#,Ssl,Iis 6,Directoryservices,我正试图通过C#代码在IIS6中自动生成站点。我正在使用DirectoryServices,我就快到了。。我有它创建的网站,设置所有的绑定等刚刚好。我还没有弄清楚如何安装我们的通配符ssl证书。以下是详细信息: 我们有一个与“*.example.com”匹配的SSL证书。 我们托管的每个站点都有一个匹配的服务器绑定。e、 g.“test.example.com”。 我想我知道如何添加SecureBinding属性: DirectoryEntrySite.Properties["SecureBin

我正试图通过C#代码在IIS6中自动生成站点。我正在使用DirectoryServices,我就快到了。。我有它创建的网站,设置所有的绑定等刚刚好。我还没有弄清楚如何安装我们的通配符ssl证书。以下是详细信息:

我们有一个与“*.example.com”匹配的SSL证书。 我们托管的每个站点都有一个匹配的服务器绑定。e、 g.“test.example.com”。 我想我知道如何添加SecureBinding属性:

DirectoryEntrySite.Properties["SecureBindings"][0] = "xx.xx.xx.xx:443:test.example.com";
但是我没有成功地找到有关如何将证书自动安装到站点的信息。在IIS 6管理器中,您可以通过右键单击站点->属性->目录安全->服务器证书->下一步->分配现有证书->(选择证书)->下一步来完成此操作

有人能帮忙吗?

请看以下内容:

见此:


好的,这个问题已经回答了,但是获得的答案不是IIS6,而是IIS7及更高版本。命名空间Microsoft.Web.Administration不适用于IIS6。为了实现这一目标,我们采用了一系列技术,全部采用.NET4.0

步骤

  • 添加对COM组件IIS CertObj 1.0类型库的引用
  • 在添加的参考CERTOBJLib的属性表中,设置 “嵌入互操作类型”为false
  • 使用以下方法创建一个类



  • 注意:如果收到错误“无法嵌入互操作类型'CERTOBJLib.IISCertObjClass'。请改用适用的接口”。这意味着跳过了步骤2。确保未嵌入参考对象。

    好的,这个问题已经回答,但授予的答案不是IIS6,而是IIS7及更高版本。命名空间Microsoft.Web.Administration不适用于IIS6。为了实现这一目标,我们采用了一系列技术,全部采用.NET4.0

    步骤

  • 添加对COM组件IIS CertObj 1.0类型库的引用
  • 在添加的参考CERTOBJLib的属性表中,设置 “嵌入互操作类型”为false
  • 使用以下方法创建一个类



  • 注意:如果收到错误“无法嵌入互操作类型'CERTOBJLib.IISCertObjClass'。请改用适用的接口”。这意味着跳过了步骤2。确保未嵌入引用对象。

    要使用.Net 4.7和IIS 10执行此操作,可以传递以下标志:

    X509Certificate2 certificate = new X509Certificate2(path, "password", X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable| X509KeyStorageFlags.MachineKeySet);
    
    如果将证书存储在CurrentUser存储区而不是LocalMachine存储区中,请执行以下操作:

    X509Certificate2 certificate = new X509Certificate2(path, "password", X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable| X509KeyStorageFlags.UserKeySet);
    
    //
    // Summary:
    //     Private keys are stored in the current user store rather than the local computer
    //     store. This occurs even if the certificate specifies that the keys should go
    //     in the local computer store.
    UserKeySet = 1,
    //
    // Summary:
    //     Private keys are stored in the local computer store rather than the current user
    //     store.
    MachineKeySet = 2,
    
    键集标志指示以下内容:

    X509Certificate2 certificate = new X509Certificate2(path, "password", X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable| X509KeyStorageFlags.UserKeySet);
    
    //
    // Summary:
    //     Private keys are stored in the current user store rather than the local computer
    //     store. This occurs even if the certificate specifies that the keys should go
    //     in the local computer store.
    UserKeySet = 1,
    //
    // Summary:
    //     Private keys are stored in the local computer store rather than the current user
    //     store.
    MachineKeySet = 2,
    

    私钥需要与证书的其余部分位于同一位置,才能与IIS一起使用。

    要使用.Net 4.7和IIS 10执行此操作,可以传递以下标志:

    X509Certificate2 certificate = new X509Certificate2(path, "password", X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable| X509KeyStorageFlags.MachineKeySet);
    
    如果将证书存储在CurrentUser存储区而不是LocalMachine存储区中,请执行以下操作:

    X509Certificate2 certificate = new X509Certificate2(path, "password", X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable| X509KeyStorageFlags.UserKeySet);
    
    //
    // Summary:
    //     Private keys are stored in the current user store rather than the local computer
    //     store. This occurs even if the certificate specifies that the keys should go
    //     in the local computer store.
    UserKeySet = 1,
    //
    // Summary:
    //     Private keys are stored in the local computer store rather than the current user
    //     store.
    MachineKeySet = 2,
    
    键集标志指示以下内容:

    X509Certificate2 certificate = new X509Certificate2(path, "password", X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable| X509KeyStorageFlags.UserKeySet);
    
    //
    // Summary:
    //     Private keys are stored in the current user store rather than the local computer
    //     store. This occurs even if the certificate specifies that the keys should go
    //     in the local computer store.
    UserKeySet = 1,
    //
    // Summary:
    //     Private keys are stored in the local computer store rather than the current user
    //     store.
    MachineKeySet = 2,
    

    私钥需要与证书的其余部分位于同一位置,才能与IIS一起使用。

    Uhmm-似乎此解决方案适用于IIS7或更高版本,而不是IIS6。命名空间Microsoft.Web.Administration不适用于IIS6。请参阅此参考资料。。。嗯-似乎这个解决方案适用于IIS7或更高版本,而不是IIS6。命名空间Microsoft.Web.Administration不适用于IIS6。请参阅此参考资料。。。如果要在IIS使用的存储中安装,请参阅。如果要在IIS使用的存储中安装,请参阅。