从.net core 6.0连接到Docker中运行的Sql边缘服务器

5lwkijsr  于 2022-12-29  发布在  Docker
关注(0)|答案(1)|浏览(121)

我一直在尝试建立一个应用程序在.net核心6. 0,但我面临的问题,而连接到sql边缘服务器运行在docker。我一直在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."

我尝试了很多方法来解决这个问题,但都无法解决。
尝试将端口号放入连接字符串中,但无法解析。

ymdaylpp

ymdaylpp1#

尝试将TrustServerCertificate=True添加到连接字符串中。
为了完整起见,下面是完整的连接字符串

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

相关问题