azdx zer0
azdx zer0

Reputation: 11

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

I recently switched from IIS Express to IIS on Windows Server. When doing the migration I had problems recognizing PHP, I did the ODBC installation, etc. However, I got the following error even though I already have an SSL certificate.

Array
(
     [0] => Array
         (
             [0] => 08001
             [SQLSTATE] => 08001
             [1] => -2146893019
             [code] => -2146893019
             [2] => [Microsoft][ODBC Driver 18 for SQL Server]SSL
Provider: The certificate chain was issued by an authority that is not
trusted.

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

         )

     [1] => Array
         (
             [0] => 08001
             [SQLSTATE] => 08001
             [1] => -2146893019
             [code] => -2146893019
             [2] => [Microsoft][ODBC Driver 18 for SQL Server]Client
unable to establish connection
             [message] => [Microsoft][ODBC Driver 18 for SQL
Server]Client unable to establish connection
         )

)

I want to believe that the problem is with the settings for the connection. The database version is Microsoft SQL Server 2019.

<?php
   $serverName = "//serverName\instanceName";
   $connectionInfo = array( "Database"=>"Database", "UID"=>"UID","PWD"=>"PWD");
   $connection = sqlsrv_connect( $serverName, $connectionInfo);

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

?>

Upvotes: 1

Views: 18450

Answers (1)

Tarmo Saluste
Tarmo Saluste

Reputation: 582

Adding parameters to the connection info worked

Encrypt=true;TrustServerCertificate=true;

Someone suggested TrustServerCertificate=Yes; that will not work nor give errors

Upvotes: 2

Related Questions