Is it possible to force mysql server authentication using django.db.backends.mysql?

it's my first question on stack overflow because I can't find relevant information in Django documentation. Is it possible to force mysql server authentication with ssl using django.db.backends.mysql? I have checked its implementation in Django Github and it seems it supports only 3 ssl arguments: ca, cert and key. What I need is equivalent of --ssl-mode=VERIFY_IDENTITY. Has anyone found some workaround for this problem? Here is my current configuration. TLS channel is working as expected, but identity of MySQL server is not validated.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': env('DB_NAME'),
        'USER': env('DB_USER'),
        'PASSWORD': env('DB_PASSWORD'),
        'HOST': env('DB_HOST'),
        'PORT': env('DB_PORT'),
        'CONN_MAX_AGE': 600,
        'OPTIONS':{
            'ssl':{
                'ca': env('CA_CERT'),
                'cert': env('CERT'),
                'key': env('KEY')
            }
        }
    }
}

Yes - but Django doesn’t expose ssl-mode directly, you must pass it through the MySQL driver (mysqlclient or PyMySQL) using OPTIONS.

Вернуться на верх