SSL [SOLVED]: Configure WordPress on Azure Cloud Service to connect to Azure MySQL over SSL

SSL [SOLVED]: Configure WordPress on Azure Cloud Service to connect to Azure MySQL over SSL

Home Forums SSL SSL [SOLVED]: Configure WordPress on Azure Cloud Service to connect to Azure MySQL over SSL

Tagged: , , , ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36770

    Anonymous

    QuestionQuestion

    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.

    #36771

    Anonymous

    Accepted AnswerAnswer

    Here is what I did:

    1. Obtain SSL certificate and save the certificate file to the root of my WordPress project.

    2. Add the following into wp-config.php:

      define('DB_SSL', true);
      
    3. Add this to the function db_connect() in my wp-includes/wp-db.php. It must be called before mysqli_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.

    Source: https://stackoverflow.com/questions/47959933/configure-wordpress-on-azure-cloud-service-to-connect-to-azure-mysql-over-ssl
    Author: Aaron Chen
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.