Long story short I have a problem establishing connection between my Web API .NET application and my SQL Server database, which I use Windows authentication for.
Once I make a request through my API controller in the application, I get back an exception
Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)
System.ComponentModel.Win32Exception (0x80090325): The certificate chain was issued by an authority that is not trusted.
I have seen all threads where people gave advice about setting Encrypt
to false and TrustServerCertificate
to true in the connection string but neither of those worked for me.
My current appsettings.json
file looks like this:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=LAPTOP-0VDNO79B\\SQLEXPRESS;Database=cv_database;Encrypt=False;TrustServerCertificate=True;"
}
}
Any advice is greatly appreciated.