I have confirmed that I have SSL remote connections working (tested from the command line mysql-client remotely).
I can’t for the life of me figure out how to make this work from PHP land though. I am novice when it comes to encryption.
This is my connection script:
# Init SQL Link
$con = mysqli_init();
if(!$con)
{
die('Init Failed');
}
mysqli_ssl_set($con,null,null,null,null,null);
mysqli_options($con,MYSQLI_OPT_SSL_VERIFY_SERVER_CERT,false);
if(!mysqli_real_connect(
$con,
'myserverip',
'myusername',
'mypassword',
'mydatabase',
3306,null,MYSQLI_CLIENT_SSL
))
{
die('No SQL');
}
The error reported to me is:
Warning: mysqli_real_connect(): (HY000/1044): Access denied for user 'myusername'@'myservername' to database 'mydatabase' in /var/www/html/public_html/test.php on line 39
I have the following SSL files (which I believe were generated via command line utility mysql_ssl_rsa_setup)
ca-key.pem
ca.pem
client-key.pem
client-cert.pem
private_key.pem
server-cert.pem
public_key.pem
server-key.pem
Would anyone happen to know which of these and in which order I use them in mysql_ssl_set()?
Please and thank you so much. No amount of Googling has lead me to the answer and I suspect it’s due to me not understanding how the Encryption works OR not understanding how my webhost has configured their mysql-client.