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