驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接

驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接,第1张

驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client preferences [TLS12]”

虽然现在大家基本上都用mysql数据库了,但是难免有时候会碰到要使用sqlserver的情况。

这时候如果你不是用微软的产品去连接,比如你用java开发,使用驱动包连接可能会碰到【驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client preferences [TLS12]”】这个错误.

低版本的驱动还可能是英文的报错【The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: “The server selected protocol version TLS10 is not accepted by client preferences [TLS12]”. ClientConnectionId:d5fd8d69-ae88-4055-9f6d-6e8515224ce2】。

这个问题其实最主要还得看后面那一句话【The server selected protocol version TLS10 is not accepted by client preferences [TLS12]】,意思是数据库服务端的协议版本是TLS10,而客户端协议版本是TLS12。

只需要在你的设备上找到jdk的安装目录【\Java\jdk1.8.0_291\jre\lib\security】下的java.security改改安全协议的配置即可。删掉这两个:TLSv1、TLSv1.1。特别要注意的是,如果你是选择了jre的运行环境来运行,那就是这个目录【\jre1.8.0_291\lib】。

修改前:

修改后:

附上springboot 连接sql server的配置代码
1、引入依赖

<dependency>
	   <groupId>com.microsoft.sqlservergroupId>
	   <artifactId>mssql-jdbcartifactId>
	   <version>8.2.2.jre8version>
dependency>

2、数据库连接配置

driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://ip:port;databasename=数据库名
username: sa
password: 密码

分享到这里就结束了,欢迎大家讨论指正。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/991283.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存