How to fix SQL Server 2019 connection error due to certificate issue

0md85ypi  于 2023-03-11  发布在  SQL Server
关注(0)|答案(1)|浏览(202)

I am using a .NET console app to test SQL Server 2019 database connection and get following error message:
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.)

The user id and password are valid. The C# code is not using any encryption. I have not configured any certificate in SQL Server configuration.

  1. Is certificate required in SQL Server 2019?
  2. Can I get a self generated cert from the SQL Server?
  3. If no self-generated cert available, where can I get a valid certificate for free?
x8diyxa7

x8diyxa71#

To improve the answer, let me sum up the comments:

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.

To install a certificate for a single SQL Server instance ( source ):

  1. In SQL Server Configuration Manager, in the console pane, expand SQL Server Network Configuration.
  2. Right-click Protocols for , and then select Properties.
  3. Choose the Certificate tab, and then select Import.
  4. Select Browse and then select the certificate file.
  5. Select Next to validate the certificate. If there are no errors, select Next to import the certificate to the local instance.

相关问题