Bug #55283 [Ver]: SSL options set by mysqli_ssl_set ignored for MySQLi persistent connections
| From: | uw@php.net | Date: | Fri, 05 Aug 2011 13:17:59 +0000 |
| Subject: | Bug #55283 [Ver]: SSL options set by mysqli_ssl_set ignored for MySQLi persistent connections | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162441@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55283&edit=1
ID: 55283
Updated by: uw@php.net
Reported by: aleksey at wepay dot com
Summary: SSL options set by mysqli_ssl_set ignored for MySQLi
persistent connections
Status: Verified
Type: Bug
Package: MySQLi related
Operating System: Cent OS
PHP Version: 5.3.6
Assigned To: mysql
Block user comment: N
Private report: N
New Comment:
The actual issue here is in mysqlnd (or in the mysqli user API, however you put it :-)): if using
mysqli_init() to create a connection object we don't yet know if it needs to be persistent or
not. mysqli was changed to meet the needs of mysqlnd. Unfortunately, this has an unforeseen
side-effect on mysqli @ libmysql [@ SSL]. Changing mysqli to make libmysql happy will cause leaks
with mysqlnd.
This needs some think time.
Previous Comments:
------------------------------------------------------------------------
[2011-08-05 11:53:47] uw@php.net
Reproducible with PHP 5.3.7RC4-dev (cli) (built: Jul 26 2011 17:35:20) (DEBUG) using *libmysql* to
connect to 5.1.45-debug-log
Configure Command => './configure' '--with-mysql=mysqlnd'
'--with-mysqli=/usr/local/mysql/bin/mysql_config'
'--with-pdo-mysql=/usr/local/mysql/bin/mysql_config' '--enable-debug'
'--enable-maintainer-zts' '--enable-mysqlnd-ms'
'--enable-mysqlenterprise' '--enable-mysqlnd-uh' '--enable-pcntl'
nixnutz@linux-fuxh:~/php/php-src/branches/PHP_5_3> sapi/cli/php bar.php
array(2) {
[0]=>
string(10) "Ssl_cipher"
[1]=>
string(18) "DHE-RSA-AES256-SHA"
}
array(2) {
[0]=>
string(10) "Ssl_cipher"
[1]=>
string(7) "RC4-MD5"
}
------------------------------------------------------------------------
[2011-07-26 00:25:00] aleksey at wepay dot com
Please note that while the example shows the problem with the cipher, all other parameters are also
ignored. In particular, ssl cert info is critical.
------------------------------------------------------------------------
[2011-07-26 00:20:58] aleksey at wepay dot com
Description:
------------
The MySQLi ignores SSL options set with mysqli_ssl_set() for persistent connections (works fine for
non-persistent connections).
To reproduce:
1) Configure MySQL server with SSL support
(http://dev.mysql.com/doc/refman/5.0/en/secure-connections.html)
2) Run the attached test script
Test script:
---------------
<?
$host = 'localhost';
$user = 'root';
$pass = '';
$db = null;
$port = 3306;
$flags = MYSQLI_CLIENT_SSL;
/* persistent connection */
$link = mysqli_init();
mysqli_ssl_set($link, null, null, null, null, "RC4-MD5");
if (mysqli_real_connect($link, 'p:' . $host, $user, $pass, $db, $port, null, $flags)) {
$r = $link->query("SHOW STATUS LIKE 'Ssl_cipher'");
var_dump($r->fetch_row());
}
/* non-persistent connection */
$link = mysqli_init();
mysqli_ssl_set($link, null, null, null, null, "RC4-MD5");
if (mysqli_real_connect($link, $host, $user, $pass, $db, $port, null, $flags)) {
$r = $link->query("SHOW STATUS LIKE 'Ssl_cipher'");
var_dump($r->fetch_row());
}
Expected result:
----------------
array(2) {
[0]=>
string(10) "Ssl_cipher"
[1]=>
string(18) "RC4-MD5"
}
array(2) {
[0]=>
string(10) "Ssl_cipher"
[1]=>
string(7) "RC4-MD5"
}
Actual result:
--------------
array(2) {
[0]=>
string(10) "Ssl_cipher"
[1]=>
string(18) "DHE-RSA-AES256-SHA"
}
array(2) {
[0]=>
string(10) "Ssl_cipher"
[1]=>
string(7) "RC4-MD5"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55283&edit=1