在Windows服务器上启⽤TLS1.2及TLS1.2基本原理介绍
⾸先在这个⽹站上测试⼀下⾃⼰的服务器究竟处于什么⽔平。
测试结果显⽰是⽀持SSL3.0的并且不⽀持TLS 1.2。证书使⽤SHA1签名算法不够强。这点⽐较容易接受,因为Windows服务器默认并没有开启TLS1.2。
要提⾼服务器的评级,有3点需要做。
使⽤SHA256签名算法的证书。
禁⽤SSL3.0,启⽤TLS1.2
禁⽤⼀些弱加密算法。
由于⽬前服务器使⽤的证书是近3年前购买的,正好需要重新购买,顺便就可以使⽤SHA256签名算法来买新的证书就可以了。在⽣产环境部署之前,先⽤测试机测试⼀下。
根据这篇⽂章中的3条命令把证书颁发机构的签名算法升级上去。测试环境是Windows2012 R2,默认的签名算法是SHA1
UpgradeCertification Authority to SHA256
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.
重新启动服务器,是设置⽣效。
由于测试机没有公⽹地址,所以去下载个测试⼯具,⽅便测试。
可以下载到EXE或者JAVA版本的测试⼯具,⽅便的在内⽹测试服务器⽀持的加密⽅式。
测试了⼀下,发现TLS1.2没有启⽤。
难道是启⽤⽅法不对?于是开始检查各种服务器的⽇志,也的确发现了TLS1.2不能建⽴的报错了。
⽹上查了很多⽂章,也没有说什么解决办法。后来换了下证书,⽤回SHA1的证书,TLS1.2就能显⽰成功启⽤了。
难道是证书有问题,于是就各种搜索SHA1证书和SHA256证书的区别,同时也测试了⼀些别⼈的⽹站,结果发现别⼈⽤SHA256证书也能⽀持TLS1.2. 难道是我的CA有问题?
⼜研究了⼏天,也测试了2008 R2的机器还是同样的问题。正好新买的公⽹证书也下来了。就拿这张证书先放到测试服务器上测试,结果还是不⾏。但是别⼈的服务器的确可以啊。
在此期间发现两篇⽐较好的⽂章,⽤Powershell来帮助我们启⽤TLS1.2以及如何设定服务器的加密算法顺序。
Setupyour IIS for SSL Perfect Forward Secrecy and TLS 1.2
EnablingTLS 1.2 on IIS 7.5 for 256-bit cipher strength
那么问题究竟出在哪呢?可能的问题,SHA256证书有问题?服务器不⽀持TLS1.2?然后根据Windows⽇志中的错误继续查,都没能到什么有⽤的信息。
于是求助朋友,朋友发来⼀段信息。
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中的⼀些信息。
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}.
ssl协议未开启的危害
- 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).
这和我遇到的问题完全符合啊,难道是客户端没有发送签名算法扩展?于是⽤IE试了下访问⽹站,发现是可以的,于是抓包看⼀下,⽤的协议是TLS1.2。证明TLS1.2在服务器上是已经启⽤的了。有client hello并且服务器也回应了serverhello。
再仔细看客户端的client hello包,⾥⾯确实包含了extension信息。
看之前测试失败并抓下来的包。并没有server hello的包回来。ClientHello⾥的确没有扩展信息。
测试⼀下,果然没有问题。这个困扰我好久的问题终于有了解释。
最后,附上不再⽀持SSL 3.0 Chrome⼚商⾃家⽹站的测试结果供⼤家参考。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。