windows-server-2008-r2 – 在IIS 7.5上一次替换多个站点上的通配符证书(使用命令行)

前端之家收集整理的这篇文章主要介绍了windows-server-2008-r2 – 在IIS 7.5上一次替换多个站点上的通配符证书(使用命令行)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有3个网站:aaa.my-domain.com,bbb.my-domain.com和ccc.my-domain.com所有在IIS 7.5上使用单个通配符证书* .my-domain.com Windows Server 2008R2 64位.该证书在一个月内到期,我的服务器上准备好了新的通配符证书* .my-domain.com.

我希望所有这些域都使用新的通配符证书,而不会出现明显的停机时间.

我尝试通过UI开始替换aaa.my-domain.com的证书:

但是当我按OK时,我收到以下错误

————————— Edit Site Binding —————————

At least one other site is using the same HTTPS binding and the binding is configured with a different certificate. Are you sure that you want to reuse this HTTPS binding and reassign the other site or sites to use the new certificate?

————————— Yes No —————————

当我单击是时,我收到以下消息:

————————— Edit Site Binding —————————

The certificate associated with this binding is also assigned to another site’s binding. Editing this binding will cause the HTTPS binding of the other site to be unusable. Do you still want to continue?

————————— Yes No —————————

此消息告诉我https://bbb.my-domain.comhttps://ccc.my-domain.com将无法使用.至少在我为这两个域名替换证书之前,我会有停机时间,对吧?

我当时认为必须有一种更聪明的方法.可能通过命令行一次替换所有网站的新通配符证书.我在网上找不到任何关于如何做到这一点的资源.有任何想法吗?

通配符和绑定相关的站点

> http://www.diaryofaninja.com/blog/2010/09/01/binding-multiple-domains-to-a-wildcard-ssl-on-a-single-ip-in-iis-75
> http://www.computer-howto.com/2011/08/running-multiple-ssl-iis-sites-iis7-75/
> https://stackoverflow.com/questions/3895675/how-to-install-wildcard-ssl-cert-on-iis-7-5
> http://blogs.msdn.com/b/asiatech/archive/2010/12/27/setting-up-a-wildcard-certificate-in-iis-7-how-to-avoid-those-certificate-mismatch-errors.aspx

与命令行绑定证书相关的站点

> IIS7 add certificate to site from command line
> https://stackoverflow.com/questions/591597/how-to-assign-a-ssl-certificate-to-iis7-site-from-command-prompt

@H_502_42@
答案的背景是IIS 7实际上并不关心证书绑定. IIS 7仅将网站绑定到一个或多个套接字.每个套接字都是IP端口的组合.资料来源: IIS7 add certificate to site from command line

因此,我们想要做的是在OS层上进行证书重新绑定.操作系统层控制SSL部分,因此您使用netsh将证书与特定套接字关联.这是通过netsh使用netsh http add sslcert完成的.

当我们将(新)证书绑定到套接字(ip端口)时,使用该套接字的所有站点都将使用新证书.

将证书绑定到套接字的命令是:
netsh http add sslcert ipport = 10.100.0.12:443 certhash = 1234567890123456789012345678901234567890 appid = {12345678-1234-1234-1234-999999999999}

如何

本部分介绍了如何逐步进行.它假设您有一些网站(aaa.my-domain.com,bbb.my-domain.com)运行即将过期的* .my-domain.com证书.您已经拥有一个已安装在服务器上但尚未应用于IIS上的网站的新证书.

首先,我们需要找出两件事.您的新证书和appid的certhash.

> certhash指定证书的SHA哈希.此哈希长度为20个字节,并指定为十六进制字符串.
> appid指定用于标识拥有应用程序的GUID,即IIS本身.

找到certhash

执行certutil命令以获取计算机上的所有证书:

certutil -store我的

我不需要所有信息,所以我这样做:

certutil -store我的| findstr / R“sha1 my-domain.com ====”

输出中,您应该在服务器上找到新证书:

================证书5 ================
主题:CN = * .my-domain.com,OU = PositiveSSL通配符,OU =域控制验证
Cert Hash(sha1):12 34 56 78 90 12 34 56 78 90 12 34 56 78 90 12 34 56 78 90

1234567890123456789012345678901234567890是我们正在寻找的certhash.它是没有空格的Cert Hash(sha1).

找到appid

让我们从looking at all certificate-socket bindings开始:

netsh http显示sslcert

或者特别是一个插座

netsh http show sslcert ipport = 10.100.0.12:443

输出

SSL Certificate bindings:
----------------------
IP:port                 : 10.100.0.12:443
Certificate Hash        : 1111111111111111111111111111111111111111
Application ID          : {12345678-1234-1234-1234-123456789012}
Certificate Store Name  : MY
Verify Client Certificate Revocation    : Enabled
Verify Revocation Using Cached Client Certificate Only    : Disabled
Usage Check    : Enabled
Revocation Freshness Time : 0
URL Retrieval Timeout   : 0
Ctl Identifier          : (null)
Ctl Store Name          : (null)
DS Mapper Usage    : Disabled
Negotiate Client Certificate    : Disabled

{12345678-1234-1234-1234-123456789012}是我们正在寻找的appid.它是IIS本身的应用程序ID.在这里你看到套接字10.100.0.12:443目前仍然绑定到旧证书(Hash 111111111 …)

将(新)证书绑定到套接

打开命令提示符并以管理员身份运行它.如果您不以管理员身份运行它,您将收到如下错误:“请求的操作需要提升(以管理员身份运行).”

首先使用此命令删除当前的证书套接字绑定

netsh http delete sslcert ipport = 10.100.0.12:443

你应该得到:

SSL证书已成功删除

然后使用此命令(找到here)使用此命令添加新的证书套接字绑定以及之前找到的appid和certhash(不带空格)

netsh http add sslcert ipport = 10.100.0.12:443 certhash = 1234567890123456789012345678901234567890 appid = {12345678-1234-1234-1234-123456789012}

你应该得到:

SSL证书已成功添加

DONE.您刚刚更换了绑定到此IP端口(套接字)的所有网站的证书.

原文链接:https://www.f2er.com/windows/368420.html

猜你在找的Windows相关文章