Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Sql Edge Server running in Docker from .net core 6.0

I have been trying to build an application in .net core 6.0, but I am facing issue while connecting it to the sql edge server running in docker.I have been running it on mac.

Here is the connection string i am using in appsettings.json.

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

I get this runtime error whenever i am trying to connect to the server.

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."

I have tried many things to clear this issue but couldn't resolve this.

Tried putting port number in the connection string but it didn't resolve.

like image 223
Amit Kumar Panda Avatar asked Sep 02 '25 17:09

Amit Kumar Panda


1 Answers

Try adding TrustServerCertificate=True to your connection string.

For the sake of completeness, here's the full connection string

Data Source=localhost,65356;Initial Catalog=MyDatabase;User=aUser;Password=aPassword;TrustServerCertificate=True
like image 197
Fabooo Avatar answered Sep 05 '25 06:09

Fabooo