|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests |
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Jan 05 10:00:02 2026 UTC |
Description: ------------ Trying to connect to a MariaDB instance using a SSL encrypted connection may fail. If it does, an PDOException's getMessage() method returns only an incomplete string. The returned error message defies any usefulness because the actual reason is not part of it. It's possible to workaround this since the exception object in question got a previous exception which holds the missing part. Though, actually expected is that method getMessage() already returns a proper message. Test script: --------------- try { $pdo = new PDO( 'mysql:host=localhost.localdomain;dbname=foo', 'foo', 'bar', array( PDO::MYSQL_ATTR_SSL_KEY => '/home/vagrant/newcerts/server-key.pem', PDO::MYSQL_ATTR_SSL_CERT => '/home/vagrant/newcerts/server-cert.pem', PDO::MYSQL_ATTR_SSL_CA => '/home/vagrant/newcerts/ca.pem', PDO::MYSQL_ATTR_SSL_CIPHER => 'DHE-RSA-AES256-GCM-SHA384' ) ); } catch (PDOException $e) { echo '# Actual:' . PHP_EOL; echo $e->getMessage() . PHP_EOL; echo '# Expected:' . PHP_EOL; echo $e->getMessage() . $e->getPrevious()->getMessage() . PHP_EOL; } Expected result: ---------------- # Actual: SQLSTATE[HY000] [2002] PDO::__construct(): SSL operation failed with code 1. OpenSSL Error messages: error:140830B5:SSL routines:ssl3_client_hello:no ciphers available # Expected: SQLSTATE[HY000] [2002] PDO::__construct(): SSL operation failed with code 1. OpenSSL Error messages: error:140830B5:SSL routines:ssl3_client_hello:no ciphers available Actual result: -------------- # Actual: SQLSTATE[HY000] [2002] # Expected: SQLSTATE[HY000] [2002] PDO::__construct(): SSL operation failed with code 1. OpenSSL Error messages: error:140830B5:SSL routines:ssl3_client_hello:no ciphers available