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

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

相关推荐
UXbot1 小时前
UI设计工具推荐合集
前端·人工智能·ui
Tandy12356_3 小时前
手写TCP/IP协议栈——HTTP协议实现(完结篇)
c语言·网络·网络协议·tcp/ip·计算机网络·http
yangSnowy3 小时前
webSocket 通信详解
网络·websocket·网络协议
上海云盾安全满满4 小时前
如何隐藏业务的IP
网络·网络协议·tcp/ip
雨季6665 小时前
使用 Flutter for OpenHarmony 构建基础 UI 组件布局:从 Scaffold 到 Container 的实战解析
flutter·ui
“αβ”6 小时前
TCP相关实验
运维·服务器·网络·c++·网络协议·tcp/ip·udp
上海云盾-小余7 小时前
高防 IP 如何弥补传统防护的短板
网络·网络协议·tcp/ip
发光小北7 小时前
MS-HUB_P特点与功能介绍
网络协议
詹某某34118 小时前
网站被提示“不安全”怎么解决
网络协议·https·ssl
发光小北9 小时前
MS-HUB-M特点与功能介绍
网络协议