How to Fix the Certificate Chain was Issued by An Authority That is Not Trusted

In previous post, we have written an article about SSL error that you might find, it is something like ERR_SSL_VERSION_OR_CIPHER_MISMATCH and how to mixed content issue HTTPS.

Here is other error that you can find when connecting SQL server database from ASP.NET core:

Unhandled 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.)

...

In this article, we will advise you how to fix above error.

Why You See This Error

The ASP.NET Core client does not by default trust SQL Server’s usage of a self-signed SSL certificate to encrypt the connection to the database, which is the cause of the problem.

The connection string that was receiving the error is as follows:

"Server=localhost; Database=my-database; User Id=dbuser; Password=*******;"

How to Fix The Issue

You can just add TrustServerCertificate=true to the connection string in order to set ASP.NET Core to accept the server certificate and resolve the issue.

The connection string that resolved the SSL error is as follows:

"Server=localhost; Database=my-database; User Id=dbuser; Password=*******; TrustServerCertificate=true;"

Conclusion

We hope above article can help you to fix error The certificate chain was issued by an authority that is not trusted.

Are you looking for an affordable and reliable Asp.net core hosting solution?

Get your ASP.NET hosting as low as $1.00/month with ASPHostPortal. Our fully featured hosting already includes

  • Easy setup
  • 24/7/365 technical support
  • Top level speed and security
  • Super cache server performance to increase your website speed
  • Top 9 data centers across the world that you can choose.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *