Bug #76714 [Com]: Collision between MySQL SSL connection and OpenSSL create key

From: Date: Tue, 07 Aug 2018 09:07:11 +0000
Subject: Bug #76714 [Com]: Collision between MySQL SSL connection and OpenSSL create key
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216659@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76714&edit=1 ID: 76714 Comment by: michel at ingenie dot fr Reported by: michel at ingenie dot fr Summary: Collision between MySQL SSL connection and OpenSSL create key Status: Feedback Type: Bug Package: MySQLi related Operating System: ubuntu 16.04 PHP Version: 7.0.31 Block user comment: N Private report: N New Comment: adding : while ($msg = openssl_error_string()) echo $msg."\n"; after the key creation display : error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value And the mysqli error does not happen. The second query work fine. So adding "while ($msg = openssl_error_string());" after the "openssl_pkey_new" seems to be a good workaround. Thanks for your help. Previous Comments: ------------------------------------------------------------------------ [2018-08-07 07:42:21] requinix@php.net What if you call openssl_error_string() after using openssl_pkey_new? ------------------------------------------------------------------------ [2018-08-07 07:28:38] michel at ingenie dot fr Description: ------------ When using SSL connection with mysqli, the use of openssl function to create a key disrupt the mysqli connection. Many thanks for your attention. Test script: --------------- <?php $mysqli = new mysqli(); $mysqli->ssl_set('/etc/mysql/ssl/client-key.pem','/etc/mysql/ssl/client-cert.pem','/etc/mysql/ssl/ca-cert.pem',null,null); $mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT,false); $mysqli->real_connect('remote.host.com','login','password',null,null,null,MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT); // test SQL query : WORK FINE $mysqli->select_db('test'); $result = $mysqli->query('select * from test'); print_r($result->fetch_all()); // Create KEY $key = openssl_pkey_new(['digest_alg' => 'sha256','private_key_bits' => 1024,'private_key_type' => OPENSSL_KEYTYPE_RSA]); // test SQL query : FAIL $mysqli->select_db('test'); // this is line 19 $result = $mysqli->query('select * from test'); print_r($result->fetch_all()); Expected result: ---------------- Just a dump of returned array like for the first select. Actual result: -------------- PHP Warning: mysqli::select_db(): SSL operation failed with code 1. OpenSSL Error messages: error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value in .../test_bug_mysql_ssl_openssl.php on line 19 Warning: mysqli::select_db(): SSL operation failed with code 1. OpenSSL Error messages: error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value in .../test_bug_mysql_ssl_openssl.php on line 19 PHP Warning: mysqli::select_db(): MySQL server has gone away in .../test_bug_mysql_ssl_openssl.php on line 19 Warning: mysqli::select_db(): MySQL server has gone away in .../test_bug_mysql_ssl_openssl.php on line 19 PHP Warning: mysqli::select_db(): Error while reading INIT_DB's OK packet. PID=16092 in .../test_bug_mysql_ssl_openssl.php on line 19 Warning: mysqli::select_db(): Error while reading INIT_DB's OK packet. PID=16092 in .../test_bug_mysql_ssl_openssl.php on line 19 PHP Fatal error: Uncaught Error: Call to a member function fetch_all() on boolean in .../test_bug_mysql_ssl_openssl.php:21 Stack trace: #0 {main} thrown in .../test_bug_mysql_ssl_openssl.php on line 21 Fatal error: Uncaught Error: Call to a member function fetch_all() on boolean in .../test_bug_mysql_ssl_openssl.php:21 Stack trace: #0 {main} thrown in .../test_bug_mysql_ssl_openssl.php on line 21 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76714&edit=1

« previous php.bugs (#216659) next »