在Windows服務器上啟用TLS 1.2及TLS 1.2基本原理介紹
首先在這個網站上測試一下自己的服務器究竟處于什么水平。
https://www.ssllabs.com/ssltest/
測試結果顯示是支持SSL3.0的并且不支持TLS 1.2。證書使用SHA1簽名算法不夠強。這點比較容易接受,因為Windows服務器默認并沒有開啟TLS1.2。
要提高服務器的評級,有3點需要做。
使用SHA256簽名算法的證書。
禁用SSL3.0,啟用TLS1.2
禁用一些弱加密算法。
由于目前服務器使用的證書是近3年前購買的,正好需要重新購買,順便就可以使用SHA256簽名算法來買新的證書就可以了。在生產環(huán)境部署之前,先用測試機測試一下。
根據這篇文章中的3條命令把證書頒發(fā)機構的簽名算法升級上去。測試環(huán)境是Windows2012 R2,默認的簽名算法是SHA1
UpgradeCertification Authority to SHA256
http://blogs.technet.com/b/pki/archive/2013/09/19/upgrade-certification-authority-to-sha256.aspx
certutil -setreg ca\csp\CNGHashAlgorithm SHA256
net stop certsvc
net start certsvc
然后,在服務器中添加注冊表鍵值并重啟已啟用TLS1.2和禁用SSL3.0
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS1.2\Server\Enabled REG_DWORD類型設置為1.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL3.0\Server Enabled REG_DWORD類型設置為0.
重新啟動服務器,是設置生效。
由于測試機沒有公網地址,所以去下載個測試工具,方便測試。
http://www.bolet.org/TestSSLServer/
可以下載到EXE或者JAVA版本的測試工具,方便的在內網測試服務器支持的加密方式。
測試了一下,發(fā)現(xiàn)TLS1.2沒有啟用。
難道是啟用方法不對?于是開始檢查各種服務器的日志,也的確發(fā)現(xiàn)了TLS1.2不能建立的報錯了。
網上查了很多文章,也沒有說什么解決辦法。后來換了下證書,用回SHA1的證書,TLS1.2就能顯示成功啟用了。
難道是證書有問題,于是就各種搜索SHA1證書和SHA256證書的區(qū)別,同時也測試了一些別人的網站,結果發(fā)現(xiàn)別人用SHA256證書也能支持TLS1.2. 難道是我的CA有問題?
又研究了幾天,也測試了2008 R2的機器還是同樣的問題。正好新買的公網證書也下來了。就拿這張證書先放到測試服務器上測試,結果還是不行。但是別人的服務器的確可以啊。
在此期間發(fā)現(xiàn)兩篇比較好的文章,用Powershell來幫助我們啟用TLS1.2以及如何設定服務器的加密算法順序。
Setupyour IIS for SSL Perfect Forward Secrecy and TLS 1.2
https://www.hass.de/content/setup-your-iis-ssl-perfect-forward-secrecy-and-tls-12
EnablingTLS 1.2 on IIS 7.5 for 256-bit cipher strength
http://jackstromberg.com/2013/09/enabling-tls-1-2-on-iis-7-5-for-256-bit-cipher-strength/
那么問題究竟出在哪呢?可能的問題,SHA256證書有問題?服務器不支持TLS1.2?然后根據Windows日志中的錯誤繼續(xù)查找,都沒能找到什么有用的信息。
于是求助朋友,朋友發(fā)來一段信息。
TLS 1.2introduced signature algorithms extension where the client advertises supportedsignature and hash algorithm combinations. When the client offers TLS1.2 without signature algorithms extension,schannel server assumes that this client only understands SHA1. If the schannelserver only has a SHA256 certificate, it will terminate the handshake. However,the same client offering TLS≤1.1 will succeed.
同時也提到了RFC5246中的一些信息。
http://www.ietf.org/rfc/rfc5246.txt
If the clientdoes not send the signature_algorithms extension, the
server MUST do the following:
- Ifthe negotiated key exchange algorithm is one of (RSA, DHE_RSA,
DH_RSA, RSA_PSK, ECDH_RSA, ECDHE_RSA),behave as if client had
sent the value {sha1,rsa}.
- Ifthe negotiated key exchange algorithm is one of (DHE_DSS,
DH_DSS), behave as if the client had sentthe value {sha1,dsa}.
- Ifthe negotiated key exchange algorithm is one of (ECDH_ECDSA,
ECDHE_ECDSA), behave as if the client hadsent value {sha1,ecdsa}.
Note: this is a change from TLS 1.1 wherethere are no explicit
rules, but as a practical matter one canassume that the peer
supports MD5 and SHA-1.
Note: this extension is not meaningful forTLS versions prior to 1.2.
Clients MUST NOT offer it if they areoffering prior versions.
However, even if clients do offer it, therules specified in [TLSEXT]
require servers to ignore extensions they donot understand.
Servers MUST NOT send this extension. TLS servers MUST support
receiving this extension.
When performing session resumption, thisextension is not included in
Server Hello, and the server ignores theextension in Client Hello
(if present).
這和我遇到的問題完全符合啊,難道是客戶端沒有發(fā)送簽名算法擴展?于是用IE試了下訪問網站,發(fā)現(xiàn)是可以的,于是抓包看一下,用的協(xié)議是TLS1.2。證明TLS1.2在服務器上是已經啟用的了。有client hello并且服務器也回應了serverhello。
再仔細看客戶端的client hello包,里面確實包含了extension信息。
看之前Testtlsserver.exe測試失敗并抓下來的包。并沒有server hello的包回來。ClientHello里的確沒有擴展信息。
于是,讓同事幫忙把測試服務器發(fā)布到公網上,用https://www.ssllabs.com/ssltest/
測試一下,果然沒有問題。這個困擾我好久的問題終于有了解釋。
最后,附上不再支持SSL 3.0 Chrome廠商自家網站的測試結果供大家參考。
相關文章
IIS7 全新管理工具AppCmd.exe的命令使用實例分享
IIS 7 提供了一個新的命令行工具 Appcmd.exe,可以使用該工具來配置和查詢 Web 服務器上的對象,并以文本或 XML 格式返回輸出2013-04-04Windows Server 2008 r2服務器無故自動重啟故障的解決方法
Windows Server 2008服務器自動重啟!登陸服務器之后,隨便做什么操作,一兩分鐘服務器就自動重啟,這里就給大家分享一下解決方法2020-02-02windows?server?2012安裝FTP并配置被動模式指定開放端口
本文主要介紹了windows?server?2012安裝FTP并配置被動模式指定開放端口,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-06-06iis Win32狀態(tài)數(shù)值(sc-win32-status)說明
在iis的日志里面,有一項是sc-win32-status,這個的中文名字就是Win32狀態(tài),那么,該狀態(tài)不同的數(shù)值代表什么呢?2008-07-07