当前位置:   首页安装配置

在Windows主机上启用TLS 1.2及TLS 1.2基本原理介绍

发布日期:2022-03-08 10:24 | 文章来源:CSDN

首先在这个网站上测试一下自己的主机究竟处于什么水平。

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厂商自家网站的测试结果供大家参考。

联系我们
关于使用场景和技术架构的更多咨询,请联系我们的销售和技术支持团队。
Yingsoo Host

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部