1 year ago

#281745

test-img

Norbert Wimmer

php-PDO connection Ubuntu to Windows MSSQL

any hint would be appreciated:

Situation: Connection with MSSQL-DB works only with sqlcmd -C, pdo-sqlsrv doesnt't work at all.

"Client hh.hh.hh.hh"

Ubuntu 20.04.4

PHP 8.0.16

OPENSSL Version 1.1.m

odbcinst shows only one line "[ODBC Driver 18 for SQL SERVER]"

phpinfo shows "PDO drivers dblib,mysql,odbc,sqlite"

"remote" DB-Server hh.hh.hh.hh+x

Windows Version ??

SQL Server 2012 SP4-GDR ....

What works/doesn't work:

+php: msqli_connect to mysql-Server on local hh.hh.hh.hh works.

-php: pdo(sqlsrv:Server=hh.hh.hh.hh+x,PORT;Database=DBNAME,USER,PASSWORD);) throws "Fatal error: Uncaught PDOException: SQLSTATE[08001]: [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate :certificate verify failed:self signed certificate]

+bash: sqlcmd connect to remote MSSQL-DB with param -C works

-bash: without param "-C" sqlcmd connect to remote MSSQL-DB throws error:1416F086("... certificate verify vailed:self_signed_certificate")

What I tried:

  • setting up an option-Array containing "TrustServerCertificate => true" and passing this to the pdo .... nothing happening, still the same error.

  • optionally using Parameter "Encrypt = true" in the option arry.

Help would be heartily welcome

kind regards

Norbert

php

pdo

sqlsrv

0 Answers

Your Answer

Accepted video resources