错误

Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)

---> System.ComponentModel.Win32Exception (0x80090325): The certificate chain was issued by an authority that is not trusted.


SQL Server 强制加密

如果目标服务器是启用了“强制加密”属性和自签名证书的本地 SQL Server,则将建立加密连接,为此,客户端必须与服务器建立信任关系。

建议的解决方案:

以下两个可用选项可修复此问题:

  • 在客户端环境中安装目标 SQL Server 的 TLS/SSL 证书。 如果需要加密,将对其进行验证。
  • (不太安全)在连接字符串中设置“TrustServerCertificate=true”属性。


不安全的解决方案:禁用 SQL Server 上的“强制加密”设置。


更多查看: https://learn.microsoft.com/zh-CN/sql/connect/ado-net/sqlclient-troubleshooting-guide?view=sql-server-linux-2017