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

本文解决在Centos8上使用Druid连接SQLServer数据库时,因TLS版本不匹配导致的连接失败问题。提供了两种解决方案:一是修改java.security文件中3DES_EDE_CBC配置;二是将openjdk替换为Oracle JDK。

 

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

 

2.方法1

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

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

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

3.方法2 

将系统的openjdk 修改为Oracle jdk

openjdk 更改为Oracle jdk

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值