Here is my code to connect to my remote DB:
$con = mysqli_init();
mysqli_ssl_set($con, "/etc/letsencrypt/keys/...certbot.pem", "/etc/letsencrypt/live/.../cert.pem", "/etc/letsencrypt/live/.../fullchain.pem", NULL, NULL);
$connection = mysqli_real_connect($con, self::$host, self::$user, self::$password);
self::$lastConnection = $connection;
$db = "db_prod";
Unfortunately, I cannot tell if it's actually working because if I intentionally mispell any of the characters for my certificates in mysqli_ssl_set, the connection is still successful. So how can I know for sure that this is working as intended?
Any help appreciated.
Since you have used mysqli_ssl_set to try establishing SSL connection to MySQL. The system will proceed to use it for subsequent connection request.
Hence, You may check the $connection which is the return value of mysqli_real_connect
So please amend to:
<?php
$con = mysqli_init();
mysqli_ssl_set($con, "/etc/letsencrypt/keys/...certbot.pem", "/etc/letsencrypt/live/.../cert.pem", "/etc/letsencrypt/live/.../fullchain.pem", NULL, NULL);
$connection = mysqli_real_connect($con, self::$host, self::$user, self::$password);
/////////////////
if (!$connection)
{
die("Connect Error: " . mysqli_connect_error());
}
/////////////////
self::$lastConnection = $connection;
$db = "db_prod";
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.