0

I'm trying to determine if I need to use mysqli_ssl_set to encrypt my db layer. I have a standard Amazon RDS instance that I'm connecting to with MySQL user and pass, but I'm unsure if that connection is automatically encrypted. My server is SSL-ready, but does that mean mysqli_connect is encrypted by default?

This is my code right now:

$connection = mysqli_connect(self::$host, self::$user, self::$password);
self::$lastConnection = $connection;
$db = "db_prod";
mysqli_select_db($connection, $db);
mysqli_set_charset($connection, "utf8mb4");

Do I need to add in mysqli_ssl_set too?

1 Answer 1

0

No, you have to call

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

or

$mysqli -> ssl_set(key, cert, ca, capath, cipher)

see manual https://www.php.net/manual/de/mysqli.ssl-set.php

or https://www.w3schools.com/php/func_mysqli_ssl_set.asp

2
  • I'm using Letsencrypt for my SSL. Would you happen to know how to fill in mysqli_ssl_set? I tried this: mysqli_ssl_set($con, "/var/lib/mysql/privkey.pem", "/var/lib/mysql/cert.pem", "/var/lib/mysql/chain.pem", NULL, NULL); but it doesn't work.
    – Tony Friz
    Jun 20, 2021 at 0:32
  • have you all those files correctly add to the server . Run SHOW VARIABLES LIKE '%ssl%';and see also there could be a tls problem.
    – nbk
    Jun 20, 2021 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.