netcore 连接sql server 2014 ubuntu20.04踩坑-SSL_connect: error:1425F102 .. unsupported protocol

 liunx上部署netcore  服务,数据库采用了sql server 2014 在运行服务时候无法启动遇到了错误

ERROR 2026 (HY000): SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

在docker 中部署遇到了类似的错误

System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)

 

问题的原因是ubuntu20.04将openssl 连接时,可接纳的ssl协议版本提高了,之前的版本不存在此问题

导致与对方建立ssl连接时,如果对方使用的不是TLSv1.2及以上,就会产生异常,提示不支持的协议.

 

 

 

解决方法是:

修改  /etc/ssl/openssl.cnf  

找到  oid_section = new_oids   这行

并在其下 补充以下内容

  

openssl_conf = default_conf
 
[default_conf]
ssl_conf = ssl_sect
 
[ssl_sect]
system_default = system_default_sect

 [ system_default_sect ]
MinProtocol = TLSv1
MaxProtocol = None
CipherString = DEFAULT:@SECLEVEL=1

 

 

如果运行在docker环境中,可以添加在 Dockerfile 中添加下面的指令修改  TLS版本号

RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf

 

 

seclevel=2 则必须使用 TLSv1.2  
这个可以在ubuntu20.04 openssl 的changelog中看到 

同时,同时给sql server 服务器打上  SQL Server 2014 Service Pack 1 (SP1)  补丁,否则依然会报告这个错误

补丁地址:https://support.microsoft.com/zh-tw/help/2936603/sql-server-2014-build-versions  

自己搜索也可以

本人使用用的是 https://www.microsoft.com/zh-cn/download/details.aspx?id=55738  

 

欢迎访问个人博客 blog.nnwk.net

 

posted @ 2020-09-25 15:19  Myisqq  阅读(1131)  评论(0编辑  收藏  举报