首页 > 解决方案 > MariaDB 和 PHP 的 SSL 错误

问题描述

我有问题。我正在尝试在我的 MariaDB 数据库和我的 PHP 代码之间创建 SSL 连接。在建立连接的那一刻,它在一定程度上运行良好,因为在 PHP 错误中我开始收到以下错误:MySQL 服务器已消失,失败尝试和连接中止的数量急剧增加。

这是我的代码:

$this->connection = mysqli_init();

mysqli_options($this->connection, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);

$this->connection->ssl_set('/xxx/xxx/client-key.pem', '/xxx/xx/client-cert.pem', '/xx/xxx/ca-cert.pem', NULL, NULL);

if (!$this->connection->real_connect($this->host, $this->user_db, $this->password_db, $this->database, 3306, NULL, MYSQLI_CLIENT_SSL)) {
    $this->error_connect = $this->connection->connect_error;
    return false;
} else {
    $this->setCharset();
    return true;
}

服务器或我的代码可能有什么问题?

标签: phpmysqlsslmariadb

解决方案


推荐阅读