[Fixed] [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted – Php

by
Ali Hasan
composer-php doctrine sql-server sqlsrv

Quick Fix: Ensure that the version of ODBC Driver installed on your PC matches the version of SQL Server you are using.

The Problem:

A PHP application utilizing Doctrine for database connectivity is encountering an SSL-related error when attempting to connect to a SQL Server database. The specific error message is: "[Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted". This error has emerged after the PHP version was upgraded from 8.2.0 to 8.2.9, while the setup was previously functioning correctly.

The Solutions:

Solution 1: Installing a Compatible Version of ODBC Driver

The error "SQLSTATE [08001, -2146893019]: [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted" often occurs due to a version mismatch between the SQL Server version and the ODBC Driver version installed on the client computer. To resolve this issue, you can try the following steps:

  1. Check the version of your SQL Server. This information can usually be found in the SQL Server Management Studio (SSMS) or by running the following query in SSMS:
SELECT @@VERSION;
  1. Ensure that you have installed the appropriate version of the ODBC Driver for SQL Server that is compatible with your SQL Server version. In this case, since you are using SQL Server V17, you should install ODBC Driver 17 on your PC.

  2. Download the correct ODBC Driver version from the Microsoft website. Make sure to select the version that matches your operating system and SQL Server version.

  3. Install the ODBC Driver following the provided installation instructions.

  4. Once the installation is complete, restart your computer.

  5. Attempt to connect to your SQL Server database again using your application or tool.

By installing the compatible version of the ODBC Driver, you can establish a successful connection to your SQL Server database and resolve the "SQLSTATE [08001, -2146893019]: [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted" error.

Q&A

Why do I get "SSL Provider: The certificate chain was issued by an authority that is not trusted" error using doctrine?

The error is caused by using a different version of ODBC Driver than the SQL Server version.

How to fix "SSL Provider: The certificate chain was issued by an authority that is not trusted" error?

Install the ODBC Driver version that matches the SQL Server version.

Can I use Encrypt and TrustServerCertificate to fix the error?

No, Encrypt and TrustServerCertificate are not effective.

Video Explanation:

The following video, titled "The Certificate Chain was issued by an authority that is not trusted ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

From #SQLSchool #CertificateChainError #SQLServerConnection This video includes SQL Server connection from SSMS Tool.