在Windows服务器上启用TLS 1.2及TLS 1.2基本原理介绍

在Windows服务器上启用TLS 1.2及TLS 1.2基本原理介绍,第1张

在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签名算法来买新的证书就可以了。在生产环境部署之前,先用测试机测试一下。

根据这篇文章中的3条命令把证书颁发机构的签名算法升级上去。测试环境是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版本的测试工具,方便的在内网测试服务器支持的加密方式。

测试了一下,发现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

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日志中的错误继续查找,都没能找到什么有用的信息。

于是求助朋友,朋友发来一段信息。

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).

这和我遇到的问题完全符合啊,难道是客户端没有发送签名算法扩展?于是用IE试了下访问网站,发现是可以的,于是抓包看一下,用的协议是TLS1.2。证明TLS1.2在服务器上是已经启用的了。有client hello并且服务器也回应了serverhello。



再仔细看客户端的client hello包,里面确实包含了extension信息。

看之前Testtlsserver.exe测试失败并抓下来的包。并没有server hello的包回来。ClientHello里的确没有扩展信息。


于是,让同事帮忙把测试服务器发布到公网上,用https://www.ssllabs.com/ssltest/

测试一下,果然没有问题。这个困扰我好久的问题终于有了解释。

最后,附上不再支持SSL 3.0 Chrome厂商自家网站的测试结果供大家参考。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/895702.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-14
下一篇 2022-05-14

发表评论

登录后才能评论

评论列表(0条)

保存