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);
        }

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

相关推荐
文创工作室22 分钟前
Adobe Illustrator 中文
ui·adobe·illustrator
user732639210047825 分钟前
借助AI再次理解三次握手和四次挥手
网络协议·面试
abcefg_h1 小时前
HTTP 协议版本演进:从 TCP 连接到 QUIC
网络·网络协议·http
liulilittle1 小时前
拥塞控制:公平性的不可能三角
网络·c++·网络协议·tcp/ip·计算机网络·tcp·通信
8125035337 小时前
第 8 篇:IP 地址:互联网的门牌号
网络·网络协议·tcp/ip
烛衔溟7 小时前
HarmonyOS 基础 UI 构建 —— 组件、布局与沉浸式效果
ui·华为·harmonyos
米丘8 小时前
HTTP 关于 HTTPS SSL/TLS 、 HTTP/2 特性
网络协议·https
KaMeidebaby8 小时前
卡梅德生物技术快报|细胞周期检测抗原流式分析:参数调试、软件拟合与问题排查
网络·人工智能·python·网络协议·tcp/ip·算法·机器学习
Irissgwe8 小时前
7、传输层协议 TCP
网络·网络协议·tcp/ip·tcp·三次握手·四次挥手
j7~8 小时前
【Linux】网络基础(1)--之局域网、广域网、OSI,网络协议、TCP/IP结构模型、网络传输等知识详解
网络·网络协议·tcp/ip·协议·osi·mac地址·报头