php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55385 mysqlnd doesn't connect using ssl
Submitted: 2011-08-09 13:22 UTC Modified: 2013-02-18 00:34 UTC
Votes:4
Avg. Score:2.0 ± 1.7
Reproduced:3 of 4 (75.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: fuxa_kos at unihost dot cz Assigned:
Status: No Feedback Package: MySQL related
PHP Version: 5.3.6 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fuxa_kos at unihost dot cz
New email:
PHP Version: OS:

 

 [2011-08-09 13:22 UTC] fuxa_kos at unihost dot cz
Description:
------------
mysqlnd doesn't connect using ssl, see Test script

PHP compiled with
'--with-mysql=/usr' \
'--with-mysqli=/usr/bin/mysql_config' \
works fine

but with
'--with-mysql=mysqlnd' \
'--with-mysqli=mysqlnd' \
doesn't work. from phpinfo mysqlnd part:
SSL   supported

Connect via mysql client works fine too
mysql --ssl-ca=mysql-cacert.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem -h some-mysql-55-server

Local client and libraries are 
MySQL-client-community-5.1.58-1.rhel5
MySQL-devel-community-5.1.58-1.rhel5
MySQL-shared-compat-5.5.15-1.rhel5
and same problem with
MySQL-shared-compat-5.1.58-1.rhel5

Target Mysql server (and all libraries and bin's) is 5.5.13.

System: CentOS release 5.6 (Final) in up2date state
Linux camel5 2.6.18-238.19.1.el5 #1 SMP Fri Jul 15 07:31:24 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

Test script:
---------------
var_dump($mirm = mysqli_init());
var_dump($mirm->ssl_set('client-key.pem', 'client-cert.pem', 'mysql-cacert.pem', null, null));
var_dump($mirm->real_connect('some-mysql-55-server', ...));
var_dump($mirm->error);
var_dump($mirm->errno);

Expected result:
----------------
this is working result from mysql legacy driver

object(mysqli)#3 (17) {
  ["affected_rows"]=>
  NULL
  ["client_info"]=>
  string(6) "5.1.58"
  ["client_version"]=>
  int(50158)
  ["connect_errno"]=>
  int(0)
  ["connect_error"]=>
  NULL
  ["errno"]=>
  int(0)
  ["error"]=>
  string(0) ""
  ["field_count"]=>
  NULL
  ["host_info"]=>
  NULL
  ["info"]=>
  NULL
  ["insert_id"]=>
  NULL
  ["server_info"]=>
  NULL
  ["server_version"]=>
  NULL
  ["sqlstate"]=>
  NULL
  ["protocol_version"]=>
  NULL
  ["thread_id"]=>
  NULL
  ["warning_count"]=>
  NULL
}
bool(true)
bool(true)
string(0) ""
int(0)

Actual result:
--------------
this is failed result from mysqlnd driver

object(mysqli)#3 (17) {
  ["affected_rows"]=>
  NULL
  ["client_info"]=>
  string(50) "mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $"
  ["client_version"]=>
  int(50008)
  ["connect_errno"]=>
  int(0)
  ["connect_error"]=>
  NULL
  ["errno"]=>
  int(0)
  ["error"]=>
  string(0) ""
  ["field_count"]=>
  NULL
  ["host_info"]=>
  NULL
  ["info"]=>
  NULL
  ["insert_id"]=>
  NULL
  ["server_info"]=>
  NULL
  ["server_version"]=>
  NULL
  ["sqlstate"]=>
  NULL
  ["protocol_version"]=>
  NULL
  ["thread_id"]=>
  NULL
  ["warning_count"]=>
  NULL
}
bool(true)
bool(false) !!!!!!
string(0) ""
int(0)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-10 15:21 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2011-08-10 15:21 UTC] kalle@php.net
And what is the value of $mirm->connect_error and $mirm->connect_errno? The error and errno is not populated for connection errors, so thats why they are blank
 [2011-08-11 13:12 UTC] fuxa_kos at unihost dot cz
-Status: Feedback +Status: Open
 [2011-08-11 13:12 UTC] fuxa_kos at unihost dot cz
returns
connect_error: NULL
connect_errno: int(0)

I test it from other box with same OS and Mysql 5.1, works fine! But difference this box have Mysql-server with have_openssl = YES. First case haven't Mysql server.

I can test it from another box, with PHP from Zend Server CE, then give additional fdb.
 [2011-08-11 13:20 UTC] fuxa_kos at unihost dot cz
sry, box where I wrote that works fine haven't mysqlnd. When PHP is compiled with mysqlnd (at this same box) doesn't work too.
I confirm for mysqlnd return 
real_connect: false
var_dump($mirm->connect_error); var_dump($mirm->connect_errno);
NULL
int(0)
 [2011-08-11 13:27 UTC] fuxa_kos at unihost dot cz
PHP compiled by same way (and same OS and Mysql RPM's) with mysqlnd __can__ connect from Mysql 5.5 box to 5.1. But from 5.1 to 5.5 with mysqlnd __can not__ (but with libmysql works fine) - as I reported.
 [2011-10-03 20:34 UTC] dnsdns at gmail dot com
Using PDO Mysql compiled with mysqlnd it doesnt work, if I recompile it with 
libmysql the same code works.
It seems mysqlnd doesnt use the supplied keys and doesnt initiate ssl.
I am using PHP 5.3.8

$DB = new PDO("mysql:host=hostname;dbname=ssltest", 'test','mypass', array(
  PDO::MYSQL_ATTR_SSL_KEY => '/path/client-key.pem',
  PDO::MYSQL_ATTR_SSL_CERT => '/path/client-cert.pem',
  PDO::MYSQL_ATTR_SSL_CA => '/path/cacert.pem'
));
 [2011-10-03 20:43 UTC] dnsdns at gmail dot com
I forgot to mention that PHP was compiled with openssl support so mysqlnd could 
have used it to connect.
There was no error about the connection, just the access denied coming from mysql 
5.1.
 [2011-10-18 18:56 UTC] andrey@php.net
-Status: Open +Status: Feedback
 [2011-10-18 18:56 UTC] andrey@php.net
Hi, can you provide a packet dump from the wire. mysqlnd + ssl doesn't work for localhost (unix socket) because of the limitations the PHP Streams impose on mysqlnd, but here the case seems to be different?
 [2011-10-19 12:09 UTC] dnsdns at gmail dot com
I know its not connecting with SSL, because I put a restriction on the user in 
MySQL. 
It connects fine if PHP is not compiled with mysqlnd. If it is compiled with 
that the 
sample code I provided only works if I drop the SSL restriction from MySQL 
(thats why 
I get access denied).
Will try to get a packet dump, but it takes time. 
I have reproduced this behaviour on Gentoo (trying to connect to MySQL 5.1.59 on 
the 
same box but connecting with ip) and SLES11 (using MySQL client 5.0.67 
connecting to 
another computer having 5.1) also.
 [2011-10-19 13:30 UTC] fuxa_kos at unihost dot cz
-Status: Feedback +Status: Open
 [2011-10-19 13:30 UTC] fuxa_kos at unihost dot cz
In my case it is connect via TCP (to other box), not thru socket.
 [2011-10-19 13:49 UTC] pajoye@php.net
What Andrey is asking is a wireshark dump of the network traffic between php and 
mysql while your script is trying to connect.
 [2011-10-19 13:49 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2011-10-19 13:50 UTC] pajoye@php.net
@fuxa_kos at unihost dot cz

Socket does not support SSL.
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC