xref: /PHP-5.3/ext/mysqli/tests/bug55283.phpt (revision da541ff5)
1--TEST--
2Bug #55283 (SSL options set by mysqli_ssl_set ignored for MySQLi persistent connections)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7require_once("connect.inc");
8
9if ($IS_MYSQLND && !extension_loaded("openssl"))
10	die("skip PHP streams lack support for SSL. mysqli is compiled to use mysqlnd which uses PHP streams in turn.");
11
12if (!($link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
13	die(sprintf("skip Connect failed, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
14
15$row = NULL;
16if ($res = $link->query('SHOW VARIABLES LIKE "have_ssl"')) {
17	$row = $res->fetch_row();
18} else {
19	if ($link->errno == 1064 && ($res = $link->query("SHOW VARIABLES"))) {
20		while ($row = $res->fetch_row())
21			if ($row[0] == 'have_ssl')
22				break;
23	} else {
24		die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error));
25	}
26}
27
28
29if (empty($row))
30	die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error));
31
32if (($row[1] == 'NO') || ($row[1] == 'DISABLED'))
33	die(sprintf("skip MySQL has no SSL support, [%d] %s", $link->errno, $link->error));
34
35$link->close();
36?>
37--FILE--
38<?php
39	include "connect.inc";
40	$db1 = new mysqli();
41
42
43	$flags = MYSQLI_CLIENT_SSL;
44
45	$link = mysqli_init();
46	mysqli_ssl_set($link, null, null, null, null, "RC4-MD5");
47	if (my_mysqli_real_connect($link, 'p:' . $host, $user, $passwd, $db, $port, null, $flags)) {
48		$r = $link->query("SHOW STATUS LIKE 'Ssl_cipher'");
49		var_dump($r->fetch_row());
50	}
51
52	/* non-persistent connection */
53	$link2 = mysqli_init();
54	mysqli_ssl_set($link2, null, null, null, null, "RC4-MD5");
55	if (my_mysqli_real_connect($link2, $host, $user, $passwd, $db, $port, null, $flags)) {
56		$r2 = $link2->query("SHOW STATUS LIKE 'Ssl_cipher'");
57		var_dump($r2->fetch_row());
58	}
59
60	echo "done\n";
61?>
62--EXPECTF--
63array(2) {
64  [0]=>
65  string(10) "Ssl_cipher"
66  [1]=>
67  string(7) "RC4-MD5"
68}
69array(2) {
70  [0]=>
71  string(10) "Ssl_cipher"
72  [1]=>
73  string(7) "RC4-MD5"
74}
75done