【问题标题】:Cannot connect to SQL Server due to SSL/TLS由于 SSL/TLS 无法连接到 SQL Server
【发布时间】:2021-07-14 01:15:20
【问题描述】:

自从将我的 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;"

【问题讨论】:

  • 使用 Wireshark 之类的工具来分析 TLS 握手失败的原因。这比尝试您找到的每个提示更重要。
  • @LexLi 会调查的,我觉得此时我只是把所有东西都扔在墙上

标签: linux nginx .net-core sql-server-2012 .net-5


【解决方案1】:

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

【讨论】:

  • 我确实尝试了Encrypt=True/FalseTrustServerCertificate=True/False 的一些连接字符串变体,如果这是您的想法。
  • 可能是linux用户的问题。您没有使用不同的用户来部署服务解决方案和数据库吗?
  • 正确,Linux 上的另一个用户,我的连接字符串确实具有我在 SQL Server 上创建的用户的登录凭据
猜你喜欢
  • 2017-12-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-05
  • 1970-01-01
  • 2010-10-26
  • 1970-01-01
相关资源
最近更新 更多