.net 6 ubuntu mssql A connection was successfully established with the server, but then an error o


ubuntu下升级dotnet core 3.1 至.net 5/.net6 连接数据库报错

错误信息

A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed)

解决方法:

1. 修改 openssl.conf文件(/etc/ssl/openssl.cnf):
//under 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
CipherString = DEFAULT@SECLEVEL=1


保存并退出
2. 执行命令使更改生效

source /etc/profile