首页 > 解决方案 > 由于 SSL/TLS 无法连接到 SQL Server

问题描述

自从将我的 Linux 服务器设置为托管 dotnet 应用程序以来,我一直收到此错误,它尝试连接到在 Windows 环境(2012 版)上运行的数据库引擎 SQL Server。linux服务器正在运行.Net 5,我试图在/usr/local/share/ca-certificates文件夹下有一个证书,到目前为止没有运气。我还将 nginx 配置为使用 ssl:

server {
listen        80;
listen        443 ssl;
server_name   111.111.111.111;

ssl on;

ssl_certificate /usr/local/share/ca-certificates/cert.crt;

ssl_certificate_key /usr/local/share/ca-certificates/cert.key;

location /core/ {
    proxy_pass         https://127.0.0.1:7001;
    proxy_http_version 1.1;
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection keep-alive;
    proxy_set_header   Host $host;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto $scheme;

//错误

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)

//连接字符串

"Server=111.111.111.111\\TESTDB4;Initial Catalog=Core;User ID=demo;Password=password;Integrated Security=False;TrustServerCertificate=False;Trusted_Connection=True;Encrypt=True;"

标签: linuxnginx.net-coresql-server-2012.net-5

解决方案


您需要在 Web 服务器上使用证书。我不确切知道在哪里添加它,但我想它应该包含在您的数据库连接字符串中


推荐阅读