Reputation: 41
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.
Upvotes: 4
Views: 1462
Reputation: 168
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
Upvotes: 5