IIS 8 上如何才能打开SNI支持同一IP多个SSL证书同时生效(实现共享443端口)

栏目:经验分享 作者:小天 点击: 6,410 次

SNI指是一项用于改善SSL/TLS的技术,在SSLv3/TLSv1中被启用。它允许客户端在发起SSL握手请求时(具体说来,是客户端发出SSL请求中的ClientHello阶段),就提交请求的Host信息,使得服务器能够切换到正确的域并返回相应的证书。
上面这句哪都有,没什么含金量。下面是我的理解。
SSL网站用的证书,提交到web服务器时,原本设计的是按服务器IP+端口来提交的。这样就造成了同一服务器IP的443端口,只能用一个证书。这样设计比同一IP和端口的,多主机头设计差太多。于是提出SNI标准,以后新的SSL和服务器,允许用主机头 + 端口方式提交到同一服务器上,这样就灵活多了。
 
那如何启用IIS8的SNI呢?
修改 applicationhost.config。(未研究实验)
修改注册表(这个方便)
HKLM\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\SslSniBindingInfo
默认值为空,修改为2.即可。
参数含义如下:
  1. IP:Port – Legacy SSL binding.(默认,传统的IP+端口)
  2. Hostname:Port – SSL binding using SNI. (new in IIS 8)
  3. Central Certificate Store – SSL binding using Central Certificate Store. I will discuss this in detail in my next blog. (new in IIS 8)
进入powershell检查你的SSL情况。
PS C:\Users\Administrator> netsh http show sslcert
SSL Certificate bindings:
-------------------------
    Hostname:port                : A.domain.cn:443
    Certificate Hash             : e1f2ea49eb4b3a0368504861db1b598cb08f49cf
    Application ID               : {4dc3e181-e14b-4a21-b022-59fc669b0914}
    Certificate Store Name       : WebHosting
    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
    Hostname:port                : b.domain.cn:443
    Certificate Hash             : 21a33747c5e245f5e2322531131766c77907c57d
    Application ID               : {4dc3e181-e14b-4a21-b022-59fc669b0914}
    Certificate Store Name       : WebHosting
    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
-------------------------------------------------------------
看到了两个域名对应同一个端口了吗?恭喜。
从此IIS不必再非得绕弯Nginx之类的才能支持SNI了。赞。

参考官方文档:https://docs.microsoft.com/zh-cn/iis/get-started/whats-new-in-iis-8/iis-80-server-name-indication-sni-ssl-scalability

原版英文资料:https://blogs.msdn.microsoft.com/kaushal/2012/09/04/server-name-indication-sni-with-iis-8-windows-server-2012/


------====== 本站公告 ======------
欢迎使用趣域网域名百科,我们将长期提供域名使用相关知识和投资域名的方法和技巧;并提供主机、服务器的解决问题和网站运营方法。