1. 程式人生 > >在同一個服務器(同一個IP)為不同域名綁定的免費SSL證書

在同一個服務器(同一個IP)為不同域名綁定的免費SSL證書

-s cli reat net 錯誤 city ive 吊銷證書 dom

越來越多的瀏覽器不在支持http協議了,這就要求你為你的網站必須綁定SSL證書。谷歌瀏覽器也將要在今年取消對http協議的支持,申請CA證書迫在眉睫。我購買有兩個域名,一個虛擬機,沒事鼓搗鼓搗,圖個樂趣。在阿裏雲申請了免費證書,一直用的好好的。這次過年恰遇證書更新,想一起把所有域名都升級到https。購買兩個證書分別綁定域名。順帶說一下如何阿裏雲購買免費域名,現在已經不太容易找到免費域名購買按鈕了。

【動圖示意購買免費CA】

技術分享圖片

購買完成,並分別綁定www.a.com和www.b.com 後,訪問a.com一直提示CA錯誤,發現CA證書來自www.b.com 一度懷疑自己綁定錯誤了域名,吊銷證書又重新購買,問題依舊。在IE中沒有有用的提示信息,在谷歌中會提示證書錯誤,且可以發現錯誤證書信息:

技術分享圖片 技術分享圖片

這個問題早在2012年就被發現並且提出的解決辦法,參考英文請點擊跳轉。 阿裏雲的解決方案。

Problem

As more e-commerce sites come on line and more businesses are storing and sharing sensitive documents online, the ability to host and scale secure sites are increasingly more important. Prior to Windows Server 2012, there were a couple of challenges when it comes to hosting secure sites:

隨著更多電子商務網站上線,越來越多的企業在線存儲和分享敏感信息,托管和確保安全網站的能力變得尤為重要,win server 2012之前,當托管SSL站點時有兩個挑戰:

SSL Scalability: In a multi-tenanted environment, such as a shared hosting, there is a limitation as to how many secure sites can be hosted on Windows Server, resulting in a low site-density.

SSL的可伸縮性:在多站點環境下,比如一個共享的服務器,托管的安全網站數量收到限制(只允許一個),導致安全網站密度很低。

IPv4 scarcity: Because the network end-point can only be identified with IP:Port binding, where tenants request to use the standard SSL port, 443, hosting a secure site often means offering a dedicated IP address per tenant.

IPv4地址不足,因為互聯網上的一個終端僅能靠一對IP:Port來訪問,當每個站點使用標準端口443時,意味著需要為每一個站點提供專用的IP地址。

Solution

On Windows Server 2012, IIS supports Server Name Indication (SNI), which is a TLS extension to include a virtual domain as a part of SSL negotiation. What this effectively means is that the virtual domain name, or a hostname, can now be used to identify the network end point. In addition, a highly scalable WebHosting store has been created to complement SNI. The result is that the secure site density is much higher on Windows Server 2012 and it is achieved with just one IP address.

It should be noted that in order for this feature to be used, your client browsers have to support SNI. Most modern browsers support SNI; however, Internet Explorer (of any version) on Windows XP does not support SNI.

解決方案是針對win server 2012的II7-IIS8,具體辦法可以參考原文,本文僅針對IIS8.5來說明:

文中提到的SNI(Server Name Indication)中文名稱是:需要服務器名稱指示(如圖), 這是一個一般人很難理解的中文翻譯,記住,他就是SNI。

另外非常重要的是:

  1. 無論你訪問任指向本服務器的域名,如果所有網站都沒有勾選SNI,那麽任何針對這個IP:Port的CA請求,都將返回第一個綁定的CA證書。
  2. 如果第一個站點沒有勾選,效果同第一條相同。

所以最好的解決辦法是:所有站點都選擇勾選SNI。

技術分享圖片

在同一個服務器(同一個IP)為不同域名綁定的免費SSL證書