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://learn.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++

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.