使用 C# 自动将 SSL 证书安装到 IIS 6 站点
我正在尝试通过 C# 代码自动化在 IIS 6 中生成站点的过程。我正在使用 DirectoryServices,我已经快到了。我用它来创建站点,设置所有绑定等,一切都很好。我还没弄清楚如何安装我们的通配符 ssl 证书。详细信息如下:
我们有一个与“*.example.com”匹配的 SSL 证书。 我们托管的每个站点都有一个匹配的服务器绑定。例如“test.example.com”。 我想我知道如何添加 SecureBinding 属性:
DirectoryEntrySite.Properties["SecureBindings"][0] = "xx.xx.xx.xx:443:test.example.com";
但我没有成功找到有关如何自动将证书安装到站点的信息。在 IIS 6 管理器中,您可以通过右键单击站点 -> 来完成此操作。属性->目录安全->服务器证书->下一步->分配现有证书 -> (选择证书)->接下来...
有人可以帮忙吗?
I'm trying to automate the process of generating a site in IIS 6 via C# code. I'm using DirectoryServices and I'm nearly there.. I have it creating the site, setting up all the bindings etc. just fine. I have not figured out how to install our wildcard ssl cert. Here's the details:
We have a SSL certificate that matches '*.example.com'.
Every site we host has a server binding that matches. e.g. 'test.example.com'.
I think I know how to add the SecureBinding property:
DirectoryEntrySite.Properties["SecureBindings"][0] = "xx.xx.xx.xx:443:test.example.com";
But I have had no success finding information on how to automatically install the certificate to the site. In the IIS 6 Manager, you would do this by right clicking a site -> properties -> Directory Security -> Server Certificate -> Next -> Assign an existing certificate -> (select certificate) -> Next...
Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅:http://forums.iis.net/t/1163325.aspx
See this: http://forums.iis.net/t/1163325.aspx
好的,这个问题已经有了答案,但是所授予的答案不是针对 IIS6 的,而是针对 IIS7 及更高版本的。命名空间 Microsoft.Web.Administration 不适用于 IIS6。我们在 .NET 4.0 中整合了一系列技术来实现这一目标。
步骤...
“嵌入互操作类型”为 false
要删除证书引用,请使用以下方法...
注意:如果收到错误“Interop type 'CERTOBJLib.IISCertObjClass” ' 无法嵌入。请改用适用的接口。”,这意味着跳过了步骤 2。确保参考对象未嵌入。
OK, this question is already answered, but the awarded answer is not for IIS6, but rather IIS7 and greater. The namespace Microsoft.Web.Administration is not available for IIS6. We hobbled together a series of technologies, all in .NET 4.0 to make this work.
Steps...
'Embed Interop Types' to false
to remove the cert reference, use the following method...
NOTE: if you receive error "Interop type 'CERTOBJLib.IISCertObjClass' cannot be embedded. Use the applicable interface instead.", this means step 2 was skipped. Ensure the reference object is NOT embedded.
要使用 .Net 4.7 和 IIS 10 执行此操作,您可以传递以下标志:
如果您将证书存储在 CurrentUser 存储中而不是 LocalMachine 存储中,请执行以下操作:
密钥集标志指示以下内容:
私钥需要与证书的其余部分位于同一位置才能与 IIS 一起使用。
To do this with .Net 4.7 and IIS 10, you can pass the following flags:
If you are storing the cert in the CurrentUser store rather than in the LocalMachine store, do the following:
The Key set flags indicate the following:
The private key needs to be in the same place as the rest of the certificate for it to work with IIS.