From:
Operating system: Windows
PHP version: 5.3.5
Package: MySQLi related
Bug Type: Bug
Bug description:Connect Error from MySqli (mysqlnd) when using SSL
Description:
------------
- Using PHP 5.3.5 Windows binaries (Zip package).
- extension = php_mysqli.dll is enabled in php.ini.
- trying to use mysqli::real_connect, passing MYSQLI_CLIENT_SSL in the
flags parameter.
It returns the following error:
Warning: mysqli::real_connect() [mysqli.real-connect.html]: (28000/1045):
Access denied for user 'user'@'host' (using password: YES) in
C:\Apache22\htdocs\test.php on line 25
Connect Error (1045)
If I switch to PHP 5.2.17 Windows binaries (Zip package), using the exact
same settings and script, I get the following (excerpts):
Success... host via TCP/IP
...
Ssl_cipher DHE-RSA-AES256-SHA
...
Ssl_version TLSv1
I believe the main difference (relevant to this problem) between PHP 5.2.17
and PHP 5.3.5 is that 5.2.17 uses libmysql.dll and 5.3.5 uses built-in
mysqlnd (native driver). So, it appears that libmysql.dll works with SSL,
while built-in mysqlnd (native driver) cannot use SSL. The Windows
binaries build has no way to disable/enable mysqlnd and/or libmysql. If
mysqlnd is not going to work with SSL, there should at least be another
option that can be configured at runtime with the options file.
Test script:
---------------
<?php $mysqli = new mysqli();
$mysqli->init();
if (!$mysqli->options(MYSQLI_READ_DEFAULT_FILE,
'C:/Program Files/MySQL/my.ini')) {
die('Setting MYSQLI_READ_DEFAULT_FILE failed');
}
if (!$mysqli->options(MYSQLI_READ_DEFAULT_GROUP, 'mysql')) {
die('Setting MYSQLI_READ_DEFAULT_GROUP failed');
}
if (!$mysqli->real_connect('host', 'user', 'pass',
'mydb', 3306, NULL, MYSQLI_CLIENT_SSL)) {
echo 'Connect Error (' . mysqli_connect_errno() . ')' . "<br />\n";
}
else {
echo 'Success... ' . $mysqli->host_info . "<br />\n";
$sql = "show status like '%ssl%'";
$result = $mysqli->query($sql);
while ($row = $result->fetch_array()) {
echo $row[0] . ' ' . $row[1] . "<br />\n";
}
if ($result) { $result->close(); }
}
$mysqli->close(); ?>
Expected result:
----------------
Expect a new SSL connection and a result set from the query indicating that
the connection is indeed via SSL/TLS.
Actual result:
--------------
Warning: (28000/1045): Access denied ... Connect Error (1045).
--
Edit bug report at http://bugs.php.net/bug.php?id=53795&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53795&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53795&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53795&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53795&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53795&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53795&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53795&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53795&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53795&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53795&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53795&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53795&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53795&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53795&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53795&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53795&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53795&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53795&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53795&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53795&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53795&r=mysqlcfg