Issue
We run Wordpress in a sub folder of our main .NET solution on a cloud service. We have moved our MySQL from CloudDB to Azure MySQL, however it will only connect if we set the "Enforce SSL Connection" to disabled.
The Wordpress wp-config.php has the following
define('DB_SSL', true);
I presume the issue is we need to pass a certificate, but it is not clear to me how we can set this in Wordpress so it is passed when connecting over SSL.
Solution
Here is what I did:
Obtain SSL certificate and save the certificate file to the root of my Wordpress project.
Add the following into
wp-config.php:define('DB_SSL', true);Add this to the function
db_connect()in mywp-includes/wp-db.php. It must be called beforemysqli_real_connect():// Just add this line mysqli_ssl_set($this->dbh, NULL, NULL, ABSPATH . 'BaltimoreCyberTrustRoot.crt.pem', NULL, NULL); if ( WP_DEBUG ) { mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags ); } else { @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags ); }
The solution seems a bit dirty but it works for me.
Answered By - Aaron Chen
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.