From: Ulf Wendel Date: Thu, 1 Sep 2011 13:17:16 +0000 (+0000) Subject: Check if MySQL server supports SSL and, if using mysqlnd, check if PHP streams will... X-Git-Tag: php-5.3.9RC1~281 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3eb3eb406ea5b5bcf790a43cb17352bb0ecf94e5;p=php Check if MySQL server supports SSL and, if using mysqlnd, check if PHP streams will support SSL --- diff --git a/ext/mysqli/tests/bug51647.phpt b/ext/mysqli/tests/bug51647.phpt index 833f8edbbb..b1c1e87a77 100644 --- a/ext/mysqli/tests/bug51647.phpt +++ b/ext/mysqli/tests/bug51647.phpt @@ -4,6 +4,35 @@ Bug #51647 (Certificate file without private key (pk in another file) doesn't wo query('SHOW VARIABLES LIKE "have_ssl"')) { + $row = $res->fetch_row(); +} else { + if ($link->errno == 1064 && ($res = $link->query("SHOW VARIABLES"))) { + while ($row = $res->fetch_row()) + if ($row[0] == 'have_ssl') + break; + } else { + die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error)); + } +} + + +if (empty($row)) + die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error)); + +if ($row[1] == 'NO') + die(sprintf("skip MySQL has no SSL support, [%d] %s", $link->errno, $link->error)); + +$link->close(); ?> --FILE-- query("SHOW STATUS LIKE 'Ssl_cipher'"); +require_once("connect.inc"); + +if ($IS_MYSQLND && !extension_loaded("openssl")) + die("skip PHP streams lack support for SSL. mysqli is compiled to use mysqlnd which uses PHP streams in turn."); + +if (!($link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) + die(sprintf("skip Connect failed, [%d] %s", mysqli_connect_errno(), mysqli_connect_error())); + +$row = NULL; +if ($res = $link->query('SHOW VARIABLES LIKE "have_ssl"')) { $row = $res->fetch_row(); - if ($row[1] === "") { - die('skip Server started without SSL support'); +} else { + if ($link->errno == 1064 && ($res = $link->query("SHOW VARIABLES"))) { + while ($row = $res->fetch_row()) + if ($row[0] == 'have_ssl') + break; + } else { + die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error)); } } + + +if (empty($row)) + die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error)); + +if ($row[1] == 'NO') + die(sprintf("skip MySQL has no SSL support, [%d] %s", $link->errno, $link->error)); + +$link->close(); ?> --FILE--