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

标签 c# docker macos asp.net-core-webapi azure-sql-edge

我一直在尝试在 .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/

相关文章:

c# - 如何使用命名空间在 Visual Studio 中处理主项目和子项目

c# - 截取 wpf 弹出窗口的屏幕截图

c# - 一个 MVC Controller 类可以有多个 IEnumerable 吗?

spring-boot - docker部署成功后无法连接本地主机上的应用程序

docker - (Vue) 使用 docker 网络主机名时,Axios API 调用不起作用

swift - Swift 中的递归类型定义

c# - 使用 Ajax 请求使用 Wcf 服务时配置文件错误

docker - 向Chef配置Docker镜像

iphone - 在 Objective C 中获取第一响应者

c++ - SFML:dyld:库未加载错误,即使库路径已更新