为什么TLS 1.2和TLS 1.3这两个TLS协议版本在重载下交替使用?

问题描述

我正在使用 Spring Rest 模板向外部 API 发出 GET 请求调用。此 API 尚不支持 TLS 1.3。在正常工作负载期间,与服务的连接工作正常。

在负载测试期间,我观察到一些调用失败并出现以下异常:

Remote host terminated the handshake; nested exception is javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:748)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:674)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:583)

在启用javax.debug级别的日志时,发现对于失败的调用,握手使用的是TLS1.3协议。

javax.net.ssl|DEBUG|9D|http-nio-8080-exec-28|2021-02-09 16:34:59.588 UTC|SSLSocketOutputRecord.java:71|WRITE: **TLS12** alert(close_notify),length = 10

javax.net.ssl|DEBUG|06 87|http-nio-8080-exec-176|2021-02-09 16:34:08.621 UTC|SSLSocketOutputRecord.java:71|WRITE: **TLS13** alert(handshake_failure),length = 2 

我的应用程序是在 Java 11 [openjdk 11.0.3] 中实现的。 Java 11 还支持 TLS 1.3。为了解决这个问题,我必须强制它使用 TLS1.2。

我想了解一下,Java 是如何确定要使用的 TLS 协议版本的?在这种情况下,TLS1.2 和 TLS1.3 交替使用。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)