我在配置基于ssl的持久MySQLi连接时遇到了问题。如有任何建议,欢迎光临。
无持久连接:
$flags = MYSQLI_CLIENT_SSL;
$link = new mysqli();
$link->ssl_set(null, null, null, null, "RC4-MD5");
if ($link->real_connect($host, $user, $pass, $db, $port, null, $flags)) {
$r = $link->query("SHOW STATUS LIKE 'Ssl_cipher'");
var_dump($r->fetch_row());
}输出结果为
array(2) {
[0]=> string(10) "Ssl_cipher"
[1]=> string(18) "RC4-MD5"
}使用持久连接:
$flags = MYSQLI_CLIENT_SSL;
$link = new mysqli();
$link->ssl_set(null, null, null, null, "RC4-MD5");
if ($link->real_connect('p:' . $host, $user, $pass, $db, $port, null, $flags)) {
$r = $link->query("SHOW STATUS LIKE 'Ssl_cipher'");
var_dump($r->fetch_row());
}输出结果为
array(2) {
[0]=> string(10) "Ssl_cipher"
[1]=> string(0) ""
}更新:我认为这是一个php bug https://bugs.php.net/bug.php?id=55283 --对于持久连接,ssl_set()基本上被忽略了,在我的例子中,由于服务器配置的原因,这将连接降级为非ssl。
发布于 2011-07-26 05:07:48
您必须先运行mysqli::ssl_set,然后才能运行real_connect。
https://stackoverflow.com/questions/6822270
复制相似问题