springboot3.x.x 集成 连接SQL Server 2008 驱动版本和SSL套接字问题的解决

驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:"The server selected

protocol version TLS10 is not accepted by client

依赖版本

bash 复制代码
<dependency>
   <groupId>com.microsoft.sqlserver</groupId>
   <artifactId>mssql-jdbc</artifactId>
   <version>8.2.2.jre8</version>
</dependency>  

然后就出现以下情况:

驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:"The server selected protocol version TLS10 is not accepted by client preferences [TLS12]"。 ClientConnectionId:48de29ee-7f21-4742-a83b-45befd44d32e

解决方式:

  1. 网上见得最多的方法:

    1)、找到 [java.security](C:\Program Files\Java\jdk-17\conf\security\java.security) 文件(jdk17中文件路径:C:\Program Files\Java\jdk17\conf\security)

    2)、打开文件,找到jdk.tls.disabledAlgorithms 方法,解除 禁用TLSv1算法,这种比较老的算法,java8以上都默认禁止了

    复制代码
    jdk.tls.disabledAlgorithms=SSLv3, RC4, TLSv1.1, DES, MD5withRSA, \
        DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL
  2. springboot中解决方法:

    懒得去找security文件改东西了,直接在main方法中配置就好了

    复制代码
      public static void main(String[] args) {
            // 项目连接sql server, 解除禁用tlsV1的过时算法
            Security.setProperty("jdk.tls.disabledAlgorithms","SSLv3, " +
                    " RC4, TLSv1.1, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL");
            String disabledAlgorithms = Security.getProperty("jdk.tls.disabledAlgorithms");
            System.out.println("Disabled Algorithms: " + disabledAlgorithms);
            SpringApplication.run(Application.class, args);
        }

我选二,主要不想那么麻烦!!!

相关推荐
一起养小猫24 分钟前
Axure day2 基础教程完整指南
ui·axure·photoshop
阿拉伯柠檬24 分钟前
网络层协议IP(二)
linux·网络·网络协议·tcp/ip·面试
草根站起来37 分钟前
https加密证书
网络协议·http·https
白狐_7981 小时前
【计网全栈通关】第 7 篇:传输层核心——TCP 连接管理、可靠传输与流量控制
网络·网络协议·tcp/ip
小李独爱秋1 小时前
计算机网络经典问题透视:数据流的平均速率,峰值速率和突发长度各表达什么意思?
网络·网络协议·计算机网络·安全·信息与通信
YYYing.2 小时前
【计算机网络 | 第九篇】计网之传输层(三)—— TCP的拥塞控制与连接管理
网络·网络协议·tcp/ip·计算机网络
chipsense2 小时前
Ubuntu服务器上为Apache网站安装部署SSL证书详细步骤
linux·ubuntu·ssl
AI_零食2 小时前
红蓝之辨:基于 Flutter 的动静脉血动力学可视化系统开发
flutter·ui·华为·harmonyos·鸿蒙
ZePingPingZe2 小时前
深入理解网络模型之Spring Cloud微服务通信、Socket、HTTP与RPC
网络协议·spring cloud·rpc·dubbo
门思科技2 小时前
ThinkLink 基于 RPC 的 LoRaWAN 告警通知机制
网络·网络协议·rpc