How to connection from Wordpress installed on Azure App Service to Azure Database for MySQL via SSL.

Jun Kudo
3 min readJan 2, 2019

--

Introduction

The Azure Database for MySQL supports Secure Sockets Layer (SSL), and the default setting is Enable.

Even if you installed Wordpress on App Service, I want to connect with SSL.
So I will show you how to make SSL connection.

I refer to the following.

Connect Azure App Service to Azure database for MySQL and PostgreSQL via SSL
https://blogs.msdn.microsoft.com/appserviceteam/2017/05/10/connect-azure-app-service-to-azure-database-for-mysql-and-postgresql-via-ssl/

Configure SSL connectivity in your application to securely connect to Azure Database for MySQL
https://docs.microsoft.com/en-us/azure/mysql/howto-configure-ssl

Prepare an SSL certificate

To connect SSL to Azure Database for MySQL, download the PEM format certificate from the following URL.
https://www.digicert.com/CACerts/BaltimoreCyberTrustRoot.crt.pem

Upload to Web App Service

Create a bin folder in D:/home/site/wwwroot.

Upload the downloaded file.

Set it as follows from the portal.
APP SETTING NAME | MYSQL_SSL_CA
VALUE | D:\home\site\wwwroot\BaltimoreCyberTrustRoot.crt.pem

Setting up Wordpress

Configure settings for SSL connection to Wordpress.
Copy wp-config-sample.php and change it to wp-config.php and add the following.

PHP7.x

define( 'MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT ); 
define( 'MYSQL_SSL_CA', getenv('MYSQL_SSL_CA'));

PHP5.x

define('MYSQL_CLIENT_FLAGS', MYSQL_CLIENT_SSL);
define( 'MYSQL_SSL_CA', getenv('MYSQL_SSL_CA'));

Let’s set the following in addition to the environment.

define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

After that I will install Wordpress.

Please access and confirm.

Summary

Normally, since MySQL creates it in the same network, I do not think that it is necessary to make SSL connection to that,
If you use MySQL via the Internet, it is necessary to connect with SSL to some extent.
It is possible to make SSL connection easily. Please, try it.

Original Content (Japanese) : http://level69.net/archives/26207

--

--

Jun Kudo
Jun Kudo

Written by Jun Kudo

I’m Japanese, Microsoft MVP for Azure. Alibaba Cloud MVP. . https://twitter.com/jkudo

No responses yet