0

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

  • Uhm, why there are mysqli there? As I remember, if you using sqlsrv from MS, you can ignore the cert as well, and if you aren't the sysadmin, please ask the sysadmin to disable the SSL if it's inside dmz, see more https://stackoverflow.com/questions/57792377/errorsqlstate08001-microsoftodbc-driver-17-for-sql-serverencryption-not – Benyamin Limanto Mar 12 '22 at 08:08
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Mar 13 '22 at 12:35
  • Thx for your comment Benyamin Limanto. Forget about mysqli, just wanted to mention that connection from php to mysql works after switching from mysql_connect/mysql_query etc to mysqli. Replacing the mssql-functions with pdo(srvsql:... throws error above when trying to open a connection. – Norbert Wimmer Mar 13 '22 at 14:17
  • To clarify question: Is there a way to pass a parameter like "-C (trust the server certificate)" (this parameter can be used with sqlcmd, which opens the connection and works fine) to the pdo(sqlsrv:....) connection-call? As the errors from pdo(sqlsrv and sqlcmd WITHOUT "-C" seem to be the same. – Norbert Wimmer Mar 13 '22 at 14:32

0 Answers0