ID: 41778 Comment by: ilredil at yahoo dot com Reported By: mail at tobias-wassermann dot de Status: Assigned Bug Type: MySQLi related Operating System: Windows XP PHP Version: 5.2.5 Assigned To: andrey New Comment:
I am able to duplicate this with 5.0.32-Debian_7etch5-log. MySQL works fine from the CLI, but not via PHP. I also tried using mysql_connect("localhost", "myuser", "mypassword", false, MYSQL_CLIENT_SSL) and mysql_pconnect("localhost", "myuser", "mypassword", MYSQL_CLIENT_SSL) and both resulted in the same "Unable to connect to MySQL server. SSL connection error" error. Previous Comments: ------------------------------------------------------------------------ [2008-04-24 11:22:16] [EMAIL PROTECTED] Feedback given. ------------------------------------------------------------------------ [2008-04-22 20:01:24] mail at tobias-wassermann dot de Hi, reconstructed the case again - sorry for the delay - with the following code: <?php error_reporting(E_ALL); ini_set("display_errors", "1"); $conn = mysqli_init(); $conn->ssl_set("C:/proj/test/test.crt", "C:/proj/test/ca.crt", "C:/proj/test/ca2.crt", NULL, NULL); $conn->real_connect("www.iba-ag.com", "user", "pass", "db", 3306, NULL, MYSQLI_CLIENT_SSL); echo $conn->errno; $res = $conn->query("SELECT * FROM catalog"); echo " - COUNT: {$res->num_rows}"; ?> The big BUT: Everytime I connect, I got a connection and the correct count of the SELECT - it works if the ssl-files exists or not exists. So it seems to be that never ever a ssl-connection will be established now - whats the problem? I tried this with a 5.2.3 PHP on Windows and a 5.2.5 PHP on Linux - in both cases with enabled OpenSSL-support ------------------------------------------------------------------------ [2008-01-23 13:22:27] [EMAIL PROTECTED] Could you please try to use the full path instead of just giving the file name? Thanks. I can't get that error message. ------------------------------------------------------------------------ [2007-06-22 08:37:23] mail at tobias-wassermann dot de Description: ------------ If I want to connect via SSL to my MySQL-Server, mysqli_real_connect always returns this error: Warning: mysqli::real_connect() [function.mysqli-real-connect]: (HY000/2026): SSL connection error in C:\proj\wampp\htdocs\test\db\mysql_ssl.php on line 7 I use mysqli_init(), to init the mysqli-object and then use ssl_set() to set the SSL-stuff and then real_connect(). A connect with the mysql-command-line client and the ssl-ca-option works perfect - i get a ssl encrypted connection. Reproduce code: --------------- Start MySQL-Server with: mysqld-nt.exe --ssl --ssl-ca=ca.crt --ssl-cert=server.crt --ssl-key=server.pem <other params> [The key is not secured by any password or such things] Use the MySQL-Client from another machine to connect via ssl: mysql.exe -u test -h server --ssl-ca=ca.crt Check if SSL works with command line client: mysql> SHOW STATUS LIKE 'Ssl_cipher'; +---------------+--------------------+ | Variable_name | Value | +---------------+--------------------+ | Ssl_cipher | DHE-RSA-AES256-SHA | +---------------+--------------------+ 1 row in set (0.02 sec) It works. Now my PHP code: <html> <body> <?php $conn = mysqli_init(); $conn->ssl_set(NULL, NULL, "ca.crt", NULL, NULL); $conn->real_connect("server", "root", NULL, "iba", 3306, NULL, MYSQLI_CLIENT_SSL); ?> </body> </html> Expected result: ---------------- The real_connect()-call should connect via SSL to the MySQL-Server. Actual result: -------------- real_connect() doesn't connect, returns error message: Warning: mysqli::real_connect() [function.mysqli-real-connect]: (HY000/2026): SSL connection error in C:\proj\wampp\htdocs\test\db\mysql_ssl.php on line 7 I know, HY000/2026 is a MySQL error - but the command line connect with same user and same CA-Certificate works fine. I tested it also on other machines. The error occurs if the db-server is another machine as the webserver - and also occurs if it's the same pc. The problem also exists if i provide a client-certificate and key to the ssl_set()-function ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41778&edit=1