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

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

相关推荐
Irene19911 小时前
ElementPlus 与成熟后台框架对比:vue-element-plus-admin、vue-pure-admin等
前端·ui·框架·vue3
ZC跨境爬虫7 小时前
使用Claude Code开发校园交友平台前端UI全记录(含架构、坑点、登录逻辑及算法)
前端·ui·架构
DfromY9 小时前
【随手记】YOCTO下MQTT使用简记
c语言·网络协议
@insist12310 小时前
网络工程师-OSI 七层模型与 TCP/IP 协议族:核心考点全解析
网络·网络协议·tcp/ip·网络工程师·软考·软件水平考试
Linux运维技术栈12 小时前
生产环境Certbot泛域名证书全自动续期完整配置指南(Cloudflare DNS验证)
nginx·证书·ssl
UI设计兰亭妙微14 小时前
兰亭妙微UI色彩系统构建:四大属性平衡、6类色系区间与万能配色组合
ui·b端界面设计
天草二十六_简村人19 小时前
阿里云的NAT和弹性公网IP,解决ECS机器访问外网的实现方案
运维·后端·网络协议·阿里云·云计算·ip
吴声子夜歌19 小时前
Node.js——WebSocket
websocket·网络协议·node.js
嵌入式学习菌19 小时前
EMS - 电表 / 智能插座 TCP 通讯协议
网络·网络协议·tcp/ip
Southern Wind20 小时前
Vue 3 + Naive UI 企业级后台管理系统完整解析
前端·vue.js·ui·typescript