添加sqlServer数据源,本地调用成功 发布后调用后报错TLS12

Blade 已结 4 969
许浩
许浩 剑宗 2022-07-04 17:34

一、该问题的重现步骤是什么?

1.  本机调用正常  nacos配置相同 线上服务调用报错


com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "The server selected protocol version TLS10 is not accepted by client preferences [TLS12]". ClientConnectionId:1cd62d3d-36c4-467a-a1cd-e6603856e03b

        at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:3151)

        at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1912)

        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2708)

        at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2362)

        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2213)

        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1276)

        at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:861)

        at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:156)

        at com.alibaba.druid.filter.FilterAdapter.connection_connect(FilterAdapter.java:787)

        at com.alibaba.druid.filter.FilterEventAdapter.connection_connect(FilterEventAdapter.java:38)

        at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:150)

        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1654)

        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1718)

        at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2792)

Caused by: javax.net.ssl.SSLHandshakeException: The server selected protocol version TLS10 is not accepted by client preferences [TLS12]

        at sun.security.ssl.Alert.createSSLException(Unknown Source)

        at sun.security.ssl.Alert.createSSLException(Unknown Source)

        at sun.security.ssl.TransportContext.fatal(Unknown Source)

        at sun.security.ssl.TransportContext.fatal(Unknown Source)

        at sun.security.ssl.TransportContext.fatal(Unknown Source)

        at sun.security.ssl.ServerHello$ServerHelloConsumer.onServerHello(Unknown Source)

        at sun.security.ssl.ServerHello$ServerHelloConsumer.consume(Unknown Source)

        at sun.security.ssl.SSLHandshake.consume(Unknown Source)

        at sun.security.ssl.HandshakeContext.dispatch(Unknown Source)

        at sun.security.ssl.HandshakeContext.dispatch(Unknown Source)

        at sun.security.ssl.TransportContext.dispatch(Unknown Source)

        at sun.security.ssl.SSLTransport.decode(Unknown Source)

        at sun.security.ssl.SSLSocketImpl.decode(Unknown Source)

        at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)

        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)

        at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1820)

        ... 12 common frames omitted

2. 

3.


二、你期待的结果是什么?实际看到的又是什么?

    期待正常调用


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

 2.8.1

四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。

4条回答
  •  yutons
    yutons (最佳回答者)
    2022-07-04 18:09

    jdk版本太高了,jdk1.8的最新版本已经禁用了TLS1.0

    有两种办法

    1、降低jdk1.8版本

    2、修改jdk1.8的配置

    1 讨论(1)
  • 2022-07-04 18:08

    看着像是sqlserver的版本与驱动不匹配,你查一下对应版本的对应驱动,然后重新改一下依赖刷新后再启动试试。

    其他的方式可以参考这个帖子:https://liuyanzhao.com/1404694802230022146.html

    遇到这些问题推荐先把报错信息到百度搜一下,可以搜到好几页的解决方案哈。

    1 讨论(1)
  • 2022-07-05 09:44

    容器中位置
    /opt/java/openjdk/jre/lib/security

    删除前

    删除后

    1 讨论(0)
  • 2022-07-07 14:33

    用openJDK 1.8可以

    0 讨论(0)
提交回复