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 @   Myisqq  阅读(1209)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示