相关疑难解决方法(0)

从 Linux 主机连接到 SQL Server 时远程证书被拒绝

我已获得 SQL Server 的证书,该证书已成功安装并激活。我可以从日志中确认这一点:

The certificate [Cert Hash(sha1) "xxxxxxxxxxxxxxxxxxE5C050F7D75F58E4E2F"] was successfully loaded for encryption.
Run Code Online (Sandbox Code Playgroud)

只需加密连接而不信任服务器证书,即可成功使用 SSMS 连接到数据库。

我想使用 WSL 和后来的 docker 来复制它。

我正在使用一个简单的 .net 6 控制台应用程序对此进行测试:

The certificate [Cert Hash(sha1) "xxxxxxxxxxxxxxxxxxE5C050F7D75F58E4E2F"] was successfully loaded for encryption.
Run Code Online (Sandbox Code Playgroud)

如果我添加Trust Server Certificate=True;到连接字符串,这将起作用。如果没有它,连接将失败:

Unhandled exception. Microsoft.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)
 ---> System.Security.Authentication.AuthenticationException: The remote certificate was rejected …
Run Code Online (Sandbox Code Playgroud)

c# sql-server ubuntu ssl ssl-certificate

13
推荐指数
2
解决办法
3万
查看次数

标签 统计

c# ×1

sql-server ×1

ssl ×1

ssl-certificate ×1

ubuntu ×1