The server selected protocol version TLS10 is not accepted by client preferences [TLS12]
连接sqlServer报错
项目启动报错提示:The server selected protocol version TLS10 is not accepted by client preferences [TLS12]”。 ClientConnectionId:8252e571-a2d0-467b-95d0-1bacf0ac3334;com.microsoft.sqlserver.jdbc.SQLServerException: 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误
分析
版本高,新增修改
如果你是用的较新的jdk,这些方法估计都没用。为了大家不走弯路,说说我的方法。
我这里的现象是使用jdk8u161没有问题,但是升级到171之后就都不行了。
网上各种方法无果后,想到既然是升级jdk导致的,查查jdk的Release Notes吧,在171的Release Notes里果然找到一条关于ssl的安全性修复:
security-libs/javax.net.ssl
3DES Cipher Suites Disabled
To improve the strength of SSL/TLS connections, 3DES cipher suites have been disabled in SSL/TLS connections in the JDK via the jdk.tls.disabledAlgorithms Security Property.
再配合-Djavax.net.debug=ssl🤝verbose参数输出了ssl的调试信息,确定了sqlserver的ssl连接使用了3DES的算法。
保存重启,错误仍然存在,查看本地文件
其中还新增了***TLSv1, TLSv1.1,***,也删除,启动成功
原先配置
jdk.tls.disabledAlgorithms=
SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, \
DH keySize < 1024, EC keySize < 224, anon, NULL, \
include jdk.disabled.namedCurves
删除后配置
jdk.tls.disabledAlgorithms=
SSLv3, RC4, DES, MD5withRSA, \
DH keySize < 1024, EC keySize < 224, anon, NULL, \
include jdk.disabled.namedCurves
去除了TLSv1, TLSv1.1, 3DES_EDE_CBC三个配置,不同版本jdk中加入不同,注意未生效一般为没有去除干净,按照本文删除后配置进行。