Why does connection to my MySQL server in Azure fail if my app does not have SSL enabled?

Viewed 40550

I get a connection failure when I try to connect to my MySQL server in Azure from my app/client, which does not have SSL enabled. The error message is as follows:

SSL connection is required. Please specify SSL options and retry.

Is SSL mandatory when connecting to a MySQL server in Azure? Is there a way I can circumvent this requirement?

5 Answers

Option 1 In Azure portal under"Azure Database for MySQL servers"

  1. Choose the MySql server
  2. Go to Server parameters -> Select require_secure_transport parameter and update value to OFF -> save

Option 2

  1. Download the certifccate from https://www.digicert.com/CACerts/BaltimoreCyberTrustRoot.crt.pem

  2. Connect to MySql server with these certificate

    mysql -h mydemoserver.mysql.database.azure.com -u Username@mydemoserver -p --ssl-ca=/opt/ssl/BaltimoreCyberTrustRoot.crt.pem

From Docker Container to Azure MYSQL connection over SSL:

My case was slightly different but I am writing it here because the azure document https://docs.microsoft.com/en-us/azure/mysql/howto-configure-ssl doesn't tell in detail actually how the application talks to MYSQL from a docker container.

In my case I was connecting to Azure MYSQL with a docker container. I enabled the SSL setting on my MYSQL server and verified the connection using sql workbench and I was able to connect it from my local using BaltimoreCyberTrustRoot.crt.pem over SSL. But my application was throwing error message -

SSL connection is required. Please specify SSL options and retry.

I was passing the DATABASE_SSL_CERT: /etc/ssl/certs/BaltimoreCyberTrustRoot.crt.pem in my docker compose yml file.

I got to know that there are \n in the pem file that sometimes are interpreted as something else in the docker environment var. \n can be seen in each line if you open in notepad++

enter image description here

What I did to fix that is I converted the pem file to base64 and updated the same in yml file. Something like -

DATABASE_SSL_CA: LS0tLS1CRUdJTiBDRVJUSUZ...=

In some cases it also needs- DATABASE_SSL_ENABLE: "true" to force SSL connection to MYSQL.

My new yml looks like-

version: "2.2"
services:
  redis:
    image: redis:3.2.6

  ckeditor-cs:
    image: docker.cke-cs.com/cs:3.9.1
    depends_on:
      - redis
    ports:
      - "8000:8000"
    restart: always
    init: true
    environment:
      DATABASE_DRIVER: mysql
      DATABASE_HOST: efg.mysql.database.azure.com
      DATABASE_USER: user@db
      DATABASE_PASSWORD: PASS
      DATABASE_PORT: 3306
      DATABASE_SSL_CA: LS0tLS1CRUdJTiB............S0=
      DATABASE_SSL_ENABLE: "true"
      REDIS_HOST: redis
      ENVIRONMENTS_MANAGEMENT_SECRET_KEY: ABC
      LICENSE_KEY: XYZ
    volumes:
      - ~/ckeditor-cloudservice/easyimage_files:/var/cs/easyimage

Now everything is working as expected.

The reason is the SSL settings is ENABLED in the setting of Azure Database of MySQL Servers

You can choose to disable it as below:

  1. Go to Azure portal under "Azure Database for MySQL servers"
  2. Choose the MySql server
  3. Go to the Connection security menu
  4. Go to the SSL Settings section
  5. Enforce SSL connection and select DISABLED option
  6. Click the Save button at the top of the page

Though it is not recommended, here is complete detail How to disable ssl

but in short. choose "server parameters" and serach for require_secure_transport and set the value to off.

you also configure ssl in simple steps as mentioned here.

Related