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

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

相关推荐
人工干智能4 小时前
科普:你的笔记本电脑中有三个IP:127.0.0.1、无线网 IP 和局域网 IP;两个域名:localhost和host.docker.internal
网络协议·tcp/ip·电脑
anddddoooo8 小时前
域内证书维权
服务器·网络·网络协议·安全·网络安全·https·ssl
mit6.8248 小时前
[实现Rpc] 通信-Muduo库的实现 | && 完美转发 | reserve | unique_lock
c++·网络协议·rpc
IsToRestart9 小时前
什么是RPC,和HTTP有什么区别?
网络协议·http·rpc
okok__TXF9 小时前
Rpc导读
网络·网络协议·rpc
Nerd Nirvana9 小时前
OpenSSL crt & key (生成一套用于TLS双向认证的证书密钥)
linux·ssl·shell·认证·加密·tls·oepnssl
虚假程序设计9 小时前
python用 PythonNet 从 Python 调用 WPF 类库 UI 用XAML
python·ui·wpf
猫猫的小茶馆10 小时前
【网络编程】UDP协议
linux·服务器·网络·网络协议·ubuntu·udp
r_martian12 小时前
RPC:分布式系统的通信桥梁
网络·网络协议·rpc
KeLin&13 小时前
ESP32 websocket-client
网络·websocket·网络协议