linux 下连接 sql server 数据库遇到了错误:error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

参考:https://github.com/microsoft/msphpsql/issues/1112#issuecomment-643522139

在使用新的系统镜像(似乎是 ubuntu:20.04 及以后的版本)运行 sqlcmd 连接低版本数据库(如 SQL Server 2008 R2)时,可能会遇到以下错误:

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol].

经网上查找,应该是新系统升级了 openssl 的版本,提高了最低安全协议的版本,应该是为了安全,低版本的 ssl 不再被支持

解决方案:

打开修改文件:/etc/ssl/openssl.cnf
在第一行(或比较靠前的位置,如大概第 17 行往后)添加以下配置:

openssl_conf = default_conf

然后在其后面增加以下配置:

[default_conf]
ssl_conf = ssl_sect

[ssl_sect]
system_default = system_default_sect

[system_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT@SECLEVEL=1

注意 MinProtocol 这里,网上有的写的是 TLSv1.1 或者 TLSv1.0,经测试好像对我这都不管用,最后找到直接写 TLSv1 就可以成功了。

如果其它场景也遇到了类似错误,也可同样进行处理,比如 asp.net core 什么的。。。

posted @ 2021-04-28 13:11  不是豆豆  阅读(5683)  评论(0编辑  收藏  举报
友情链接:迷途