summaryrefslogtreecommitdiff
path: root/ext/mysqli/tests/bug55283.phpt
blob: d03daaee88e75f953525423598ff4b2615aa0e3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
--TEST--
Bug #55283 (SSL options set by mysqli_ssl_set ignored for MySQLi persistent connections)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
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();
} 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') || ($row[1] == 'DISABLED'))
	die(sprintf("skip MySQL has no SSL support, [%d] %s", $link->errno, $link->error));

$link->close();
?>
--FILE--
<?php
	include "connect.inc";
	$db1 = new mysqli();


	$flags = MYSQLI_CLIENT_SSL;

	$link = mysqli_init();
	mysqli_ssl_set($link, null, null, null, null, "RC4-MD5");
	if (my_mysqli_real_connect($link, 'p:' . $host, $user, $passwd, $db, $port, null, $flags)) {
		$r = $link->query("SHOW STATUS LIKE 'Ssl_cipher'");
		var_dump($r->fetch_row());
	}

	/* non-persistent connection */
	$link2 = mysqli_init();
	mysqli_ssl_set($link2, null, null, null, null, "RC4-MD5");
	if (my_mysqli_real_connect($link2, $host, $user, $passwd, $db, $port, null, $flags)) {
		$r2 = $link2->query("SHOW STATUS LIKE 'Ssl_cipher'");
		var_dump($r2->fetch_row());
	}

	echo "done\n";
?>
--EXPECTF--
array(2) {
  [0]=>
  string(10) "Ssl_cipher"
  [1]=>
  string(7) "RC4-MD5"
}
array(2) {
  [0]=>
  string(10) "Ssl_cipher"
  [1]=>
  string(7) "RC4-MD5"
}
done