How to fix error during database connection to SQL Server 2022

Nigel Mupira 20 Reputation points
2024-04-19T00:32:23.4033333+00:00

Screenshot 2024-04-19 012314

SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2024-04-19T03:30:02.3633333+00:00

    Hi @n_mupira,

    Thanks for your information.

    Please check out the article, there are breaking changes in EF Core 7.0. SqlClient connection strings use Encrypt=False by default. This means that:

    • The server must be configured with a valid ceritificate.
    • The client must trust this certificate.

    A SqlException will be thrown if these conditions are not met:

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

    There are three ways to proceed:

    1. Install a valid certificate on the server. Hope this article can help you well.
    2. If the server has a certificate, but it is not trusted by the client, then TrustServerCertificate = True to allow bypassing the normal trust mechanism.
    3. Explicitly add Encrypt=False to the connection string.

    In addition, the values accepted are yes/no, if true/false doesn't seem to work. The default value is "no", which means that the server certificate will be validated.

    However, in less sensitive environments you can let it suffice with checking "Trust server certificate", this option is on the first page.

    Best regard,

    Lucy Chen


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    https://docs.microsoft.com/en-us/answers/support/email-notifications

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.