Hi PHP Freaks,
We run a server on Windows and are running PHP 7.4.13. For several years we've been using PDO_ODBC to use our Windows ODBC data sources to connect to our third-party vendor SQLAnywhere database. It's been working great. Recently, our vendor adjusted their connections to use TLS encryption. We adjusted our Windows data sources to use that encryption method, and they all work great! That being said, we're now receiving an error: "SQLSTATE[08S01] SQLConnect: -829 [SAP][ODBC Driver] TLS handshake failure1"
When the PHP function attempts to connect. Here is the function with sensitive information changed:
function c_connect() {
global $pdo_conn;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$dsn = "odbc:MyDataSource";
$odbcusername = "MyUsername";
$odbcpassword = "MyPassword";
try {
$pdo_conn = new PDO($dsn, $odbcusername, $odbcpassword);
$pdo_conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}
catch(Exception $e) {
echo "Invalid Connection: ";
die( print_r( $e->getMessage() ) );
}
}
I've been trying to find if something specific needs to be done to the "new PDO" line to account for the encryption and get the handshake to work, but can't find any information about it whatsoever. The manual appears to not give any alternative options for PDO_ODBC other than the dsn, username and password.
Again, I've checked several times and the DSN, Username and Password are correct and the data source it's attempting to access works perfectly.
Does anyone know if additional steps need to be taken to get PDO_ODBC working to access a data source that has TLS encryption?
Kind Regards,
bendavid