In visual studio I get a message regarding SQL connection

Claude Larocque 666 Reputation points
2024-01-17T18:07:15.88+00:00

Since a couple of days, I receive this error from Visual Studio, can somebody helps me to correct the situation: A connection was successfully established with the server, but then an error occurred during the login process. (provide: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.) Clude from Quebec, Canada

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,947 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 54,646 Reputation points
    2024-01-17T19:22:23.55+00:00

    That indicates that you are using encrypted communication to SQL (which is now the default) but the cert being used isn't trusted. This is common if you have not configured your SQL Server to use a custom certificate. The generated certificate is self service and not valid across machines. To work around this change your connection string to allow any cert from the server. It generally looks something like this: Server=SomeServer;Database=SomeDatabase;Encrypt=True;TrustServerCertificate=True Now you can connect encrypted using the server's own cert. If you are getting this while trying to connect using the UI (or SSMS) then go to the connection options and you'll see the Trust Server Certificate checkbox that you need to check.


  2. ZoeHui-MSFT 37,221 Reputation points
    2024-01-18T05:42:59.7766667+00:00

    Hi @Claude Larocque,

    While setting TrustServerCertificate=True or Encrypt=false in the connection string is a quick fix, the recommended way of solving this issue is to provide a proper certificate for your SQL Server from a trusted CA.

    A same thread here you may take a reference to.

    Regards,

    Zoe Hui


    If the answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.