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

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

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Decoding the "Certificate Chain Not Trusted" Error in ODBC Connections to SQL Server

When migrating a PHP application from IIS Express to a full-blown Windows Server environment, you might expect the transition to be straightforward if your SSL certificates are already in place. However, encountering SQLSTATE 08001 with the specific message [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted indicates a fundamental mismatch between the driver's security expectations and your system's trust store. This error prevents the client from establishing a secure connection to Microsoft SQL Server 2019, even when valid certificates exist.

The root cause lies in how the ODBC Driver for SQL Server validates SSL certificates by default. When you execute sqlsrv_connect without explicitly configuring the encryption setting or providing a trusted certificate path, the driver attempts to verify the server's certificate against the Windows Certificate Trust Store. If the issuing authority (CA) is not recognized as trusted by the operating system, the handshake fails immediately. This often happens when using a self-signed certificate, a certificate from an internal PKI that hasn't been imported into the root store, or a certificate issued by a private CA that isn't pre-installed on the server.

Consider the following connection attempt where the error manifests:

<?php
   $serverName = "//serverName\instanceName";
   $connectionInfo = array( 
       "Database"  => "Database", 
       "UID"       => "UID", 
       "PWD"       => "PWD",
       "Encrypt"   => true // This defaults to false in older drivers but is often enforced or default in newer ones like Driver 18
   );
   
   $connection = sqlsrv_connect($serverName, $connectionInfo);

   if (!$connection) {
       die(print_r(sqlsrv_errors(), true));
   }
?>

In this snippet, the error log explicitly states that the certificate chain is not trusted. Simply having a certificate installed on the IIS web server does not automatically propagate trust to the database client side unless the server's root CA is present in the local machine or user certificate stores. The ODBC driver treats missing roots as a fatal error rather than a warning when Encrypt is enabled (which is often the case for modern SQL Server configurations).

To resolve this, you must ensure that the issuing authority of your SSL certificate is explicitly trusted by the machine running the PHP script. If you are using a self-signed or internally issued certificate, you need to import the root CA into the "Trusted Root Certification Authorities" store on the Windows Server. This can be done via the Microsoft Management Console (MMC) by navigating to Certificates -> Trusted Root Certification Authorities.

Alternatively, if you cannot modify the system trust store or must use a certificate that isn't in the public chain, you can force the driver to accept the connection without validating the CA hierarchy. This is achieved by setting the TrustServerCertificate option within the $connectionInfo array:

$connectionInfo = array( 
    "Database"      => "Database", 
    "UID"           => "UID", 
    "PWD"           => "PWD",
    "Encrypt"       => true,
    "TrustServerCertificate" => true // Overrides standard CA chain validation
);

Setting TrustServerCertificate to true tells the ODBC driver to skip the verification of the certificate authority chain, effectively trusting any certificate presented by the server. While this bypasses the strict security check that usually prevents man-in-the-middle attacks, it is a valid operational pattern for environments using internal PKIs or self-signed certificates where external validation is impossible.

If you are building this application within the Laravel ecosystem, similar issues can arise when configuring database connections in config/database.php. The trade-off here is between strict security enforcement and deployment flexibility. In production environments with public-facing clients, relying on a valid CA chain is mandatory. However, for isolated internal services or development servers where certificate management is complex, trusting the server certificate directly simplifies the configuration without requiring root certificate import operations.

Ultimately, the error message regarding SQLSTATE 08001 is a clear indicator that the client and server cannot agree on a mutually trusted identity. Whether you choose to import your CA into the Windows trust store or configure the driver to trust the server certificate depends on your specific security posture and infrastructure constraints. For developers managing internal SQL Server instances, understanding this distinction prevents unnecessary downtime during migrations from lightweight environments like IIS Express to robust production servers.

Our network