I want Enforce SSL connection with my Azure Database for MySQL. I followed all steps that are in Microsoft docs
I connected public certificate in Workbench and everything seems to be ok:
I also checked status in mysql CLI and in SSL I see Cipher in use is TLS_AES_256_GCM_SHA384
.
but when I am trying to runserver I get error:
django.db.utils.OperationalError: (9002, 'SSL connection is required. Please specify SSL options and retry.')
settings.py file
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': config('DB_NAME'),
'USER': config('DB_USER'),
'PASSWORD': config('DB_PASSWORD'),
'HOST': config('DB_HOST'),
'PORT': config('DB_PORT'),
'OPTIONS': {
'charset': 'utf8mb4',
'init_command': 'SET character_set_connection=utf8mb4;'
'SET collation_connection=utf8mb4_unicode_ci;'
"SET NAMES 'utf8mb4';"
"SET CHARACTER SET utf8mb4;"},
'ssl': {
'ca': '/var/www/html/BaltimoreCyberTrustRoot.crt.pem'
}
}
}
I am guessing that something is wrong with ca path but I am not sure how should I change it.
I tried to connect to MySQL db with certificate using this command in mysql CLI (as suggested here) but it when I put server and username it gives me syntax error (I put exactly what is below).
mysql -h mydemoserver.mysql.database.azure.com -u Username@mydemoserver -p --ssl-ca=/opt/ssl/BaltimoreCyberTrustRoot.crt.pem