MariaDB和PHP的SSL错误

I got a problem. I am trying to create an SSL connection between my MariaDB database and my PHP code. At the moment of making the connection it works well to a certain extent, since in the PHP errors I start to get the following error: MySQL Server has gone away and the number of failed attempts and connection abortions increase drastically.

This is my code:

$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;
}

What could be wrong with the server or my code?