gpt4 book ai didi

c# - 从 .net core 6.0 连接到在 Docker 中运行的 Sql Edge Server

转载 作者:行者123 更新时间:2023-12-05 05:30:04 25 4
gpt4 key购买 nike

我一直在尝试在 .net core 6.0 中构建应用程序,但在将它连接到在 docker 中运行的 sql edge 服务器时遇到问题。我一直在 mac 上运行它。

这是我在 appsettings.json 中使用的连接字符串。

"TheatreApiDb":"Server=localhost;Database=Theatre;User=SA;Password=P@ssw0rd;Trusted_Connection=True;"

每当我尝试连接到服务器时,我都会收到此运行时错误。

Microsoft.Data.SqlClient.SqlException: "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 by the provided RemoteCertificateValidationCallback."

我已经尝试了很多方法来解决这个问题,但无法解决这个问题。

尝试将端口号放入连接字符串中,但无法解析。

最佳答案

尝试将 TrustServerCertificate=True 添加到您的连接字符串。

为了完整起见,这里是完整的连接字符串

Data Source=localhost,65356;Initial Catalog=MyDatabase;User=aUser;Password=aPassword;TrustServerCertificate=True

关于c# - 从 .net core 6.0 连接到在 Docker 中运行的 Sql Edge Server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74798271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com