Loading
0

SQLServer JDBC 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接

网上有不少人遇到过使用jdbc连接sqlserver出错的情况,错误信息为

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“SQL Server 未返回响应。连接已关闭。 ClientConnectionId:b441ca70-fe1b-4cde-9954-4f8251d62979”。
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)

解决方法有换驱动或者添加jar包。

如果你是用的较新的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:handshake:verbose参数输出了ssl的调试信息,确定了sqlserver的ssl连接使用了3DES的算法。

修改jre\lib\security\java.security,删除jdk.tls.disabledAlgorithms中的3DES_EDE_CBC

重启服务,问题解决!

希望对大家有帮助。
————————————————
版权声明:本文为CSDN博主「chch87」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/chch87/article/details/86504581

最后编辑于:2021/10/16作者: joycode

我不入地狱,谁入地狱?

评论已关闭