skip to Main Content

using ubuntu 22, php8.2, odbc driver 18, OpenSSL 3.0.2, when I try to connect with a sqlsrv database using pdo_sqlsrv, it return me this error:

SQLSTATE[08001]: [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: [error:0A000086:SSL routines::certificate verify failed:self-signed certificate]

the code I’ve used:

<?php
$sSGBD = "sqlsrv";
$sDatabase = "db_Des";
$sServer = "10...24";
$sUser = "aplic_...";
$sPwd = "....";


try {
        if(!$oPDO) {
                $oPDO = new PDO ("$sSGBD:Server=$sServer;Database=$sDatabase","$sUser","$sPwd");
                $oPDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            }
        } catch(PDOException $e) {
              echo $e->getMessage();
        }

I have a server in production with Debian 11, php 7.3, ODBC 17, openssl 1.1 and pdo_sqlsrv and it connects well with my 2008 sqlsrv database. I’ve already tried to run the script with another server with the same specs(Debian 11, php 7.3, ODBC 17, openssl 1.1(same configuration)) but it return me the same error I got in ubuntu 22.

in my php 8.2 installation that uses ubuntu 22, I tried to connect with both sqlsrv 2008 and sqlsrv 2022 and it didn’t work.

2

Answers


  1. PDO::SQLSRV_ATTR_DIRECT_QUERY => true,
    PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE => true,
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::SQLSRV_ATTR_ENCODING => PDO::SQLSRV_ENCODING_UTF8
    
    Login or Signup to reply.
  2. TrustServerCertificate=false or TrustServerCertificate=true

    you can try it with pdo dsn parameter

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search