I’m migrating our WordPress database to RDS which is also being used by other services in our infrastructure. But I couldn’t find any configuration option for wp-config.php
where I could specify that SSL to be used while connecting to the server. This would also need a reference to the certificate authority file provided by Amazon. The app server on which WordPress is currently running, is outside AWS cluster.
The answers I could find were fairly old (I’m using WordPress 4.2 here) and don’t provide much guidance.
How can I configure WordPress to use Amazon RDS over an SSL connection (specifying the public key)?
Had the same question. Thankfully some other folks had proposed a reasonable solution here: https://core.trac.wordpress.org/ticket/28625. End-to-end, here’s what I did to get SSL working:
1. Add the following to the wordpress wp-includes/wp-db.php file. (except the last 2 lines which are just for insertion point reference)
2. Customize your wordpress wp-config.php file.
Add & customize the following lines in your wp-config.php file. You can test these from development/staging as well as production if you have multiple environments.
Note that there are 5 available MYSQL_SSL* settings you could use in your config, per code in #1 above. My RDS connection works via SSL with just the _CA option.
3. Sanity test that your connection is encrypted.
Add a quick test file to show whether the current WordPress connection is using SSL or not. Create a sample file like this one called test.php, and put in your wordpress root or somewhere web accessible. Don’t forget to remove this file when done testing.
4. Deploy and test your connection
Deploy your changes & test.php file to your wordpress installation, and restart your web server as needed. I’m using apache, so I run
For anyone one is using Redhat 7 + Apache 2.4 + PHP 7.
I was facing same issue, so added below two lines into the wp-config.php as mentioned above.
define(‘MYSQL_CLIENT_FLAGS’, MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT ); // you need this for PHP 7
define(‘MYSQL_SSL_CA’, ‘/var/www/BaltimoreCyberTrustRoot.crt.pem’);
However was still not able to connect to DB…
So called one guy and he asked me to disable the Selinux by running following command:
setsebool -P httpd_can_network_connect_db 1
I said, dude, i already disabled SELinux why i need to run this again? He screamed to me: I DON’T KNOW, JUST RUN IT!
so i did and restarted the httpd, and it worked without changing wp-db.php… dont ask me why as i totally have no idea abpit the logic behind this neither.