Updating Microsoft ODBC Drivers (17 to 18) for PHP

Filipe Pires
Nerd For Tech
Published in
2 min readJan 5, 2023

All know that PHP v7.4 lost the support, and our recent legacy applications should upgrade to PHP v8.x …

If you have applications that are using Microsoft Database connections like SQL Server, you probably are using PHP extensions pdo_sqlsrv and sqlsrv that are installed with the ODBC driver, in a Linux environment we have to update from ODBC v17 to ODBC v18 drivers to ensure the database connection for newer versions of PHP.

In a managed server, you can ask for help from support to update the drivers or if you control the server 100% you must upgrade yourself. Either way, upgrading is not the problem… when you check the applications you will see an error every time you are using a database query using a Microsoft SQL connection.

[Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate]

Above is the error you will see, so the catch here was the change for this version needs that encryption is mandatory for every database connection, as shown in the version release information.

Fortunately, there is a quick fix for this situation. In Laravel, you must change the connection array to ensure that encryption is active.
To do this, must go to the database.php file in the config folder and add these two lines (identified by the commentaries) to the [sqlsrv] connection.

database.php

Save the file, clear the config cache in Laravel and everything should work now.

Note: this article is for Laravel, but it also works for other PHP development, just add the two parameters in your database connection string and the error will go away.

--

--

Filipe Pires
Nerd For Tech

Dad, Senior Software Engineer, Game Dev & Collector, Electronic Prototyping & much more. Passionate about building the future with code.