The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL)

 

1.问题描述:

windows本地测试没有问题,linux(Centos 8)上面运行出现问题。sqlserver 数据库链接报错

报错如下

主要报错:Server chose TLSv1, but that protocol version is not enabled or not supported by the client

 

java.ext.dirs: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el8_1.x86_64/jre/lib/ext:/usr/java/packages/lib/ext
2020-06-23 16:41:10.267 [main] ERROR com.alibaba.druid.pool.DruidDataSource:936 - init datasource error,
 url: jdbc:sqlserver://192.168.0.174:1433;DatabaseName=xxx;integratedSecurity=false
com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Server chose TLSv1, but that protocol version is not enabled or not supported by the client.". ClientConnectionId:22917695-6f2a-432e-96e8-e777f4237acc

 

The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL)

2.方法1

JDK目录下的jre\lib\security,打开java.security

把3DES_EDE_CBC注释掉。保存,测试成功!

补充说明:开发环境改的是上面路径,实际生产环境修改的是JRE下的java.security

3.方法2 

将系统的openjdk 修改为Oracle jdk

openjdk 更改为Oracle jdk