PHP mysqli_ssl_set() 函数

PHP 教程 · 2019-01-28 12:27:03

实例

创建 SSL 连接:

<?php
$con=mysqli_init();
if (!$con)
{
die("mysqli_init failed");
}

mysqli_ssl_set($con,"key.pem","cert.pem","cacert.pem",NULL,NULL);

if (!mysqli_real_connect($con,"localhost","my_user","my_password","my_db"))
{
        die("Connect Error: " . mysqli_connect_error());
}

// 一些查询...

mysqli_close($con);
?>

定义和用法

mysqli_ssl_set() 函数用于创建 SSL 安全连接。然而,该函数只有在启用 OpenSSL 支持时才有效。

注释:该函数必须在 mysqli_real_connect() 之前调用。

注释:在 PHP 5.3.3 之前的版本,MySQL Native Driver 不支持 SSL。自 PHP 5.3+ 起,在微软 Windows 上默认启用 MySQL Native Driver。

语法

mysqli_ssl_set(connection,key,cert,ca,capath,cipher);

参数 描述
connection 必需。规定要使用的 MySQL 连接。
key 必需。规定密钥文件的路径名。
cert 必需。规定认证文件的路径名。
ca 必需。规定认证授权文件的路径名。
capath 必需。规定包含 PEM 格式的可信 SSL CA 认证的目录的路径名。
cipher 必需。规定用于 SSL 加密的可用密码列表。

技术细节

返回值: 总是返回 TRUE。如果 SSL 安装不正确,当您尝试连接的时候,mysqli_real_connect() 将返回一个错误。
PHP 版本: 5+

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Producing Masculinity

Producing Masculinity

Michele White / Routledge / 2019-3 / $39.95

Thoughtful, witty, and illuminating, in this book Michele White explores the ways normative masculinity is associated with computers and the Internet and is a commonly enacted online gender practice. ......一起来看看 《Producing Masculinity》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试