Hi I try to connect my asp.net core api to a sql server database I encounter an error like: "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 provided by an authority that is not trusted.)", this error I encountered long before and had add the following properties: "TrustServerCertificate=True" and "Trusted_connection=True" but I encounter the same error I added these properties but I have the same error, what can cause this?

I would say that the best solution is to talk with your IT folks to have a proper certificate installed on the SQL Server machine, and added to the trusted certificate store on the clients.

By the way, Trusted_connection is just a synonym for Integrated Security. It is not relation to connection security as such.

Probably your SQL Server does not support TLS 1.2. Please see the following Microsoft document:

Login-phase errors

There was change in Microsoft.Data.SqlClient 4.0 as described below:

New features in 4.0

"The default value of the Encrypt connection setting has been changed from false to true."

Hello,

1 - Check the type of authentication configured on the SQL Server.

2 - See the example below of a complete connection string, and adapt it to your data:

"ConnectionStrings": {

"DefaultConnection": "Server=MyServerNameOrHostIP,PortNumber;Initial Catalog=Mydatabse;User Id=YourUser;Password=YourPassword;Persist Security Info=False;Trusted_Connection=False;Encrypt=False;TrustServerCertificate=True;"

If it works or you need clarification, leave a comment.