SSL DB connection error

I have enabled encrypted connections with my database (MariaDB) with

    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'USER': 'xx',
        'HOST': 'xx',
        'PASSWORD': 'xx',
        'NAME': 'xx',
        'PORT': '',
        'OPTIONS': {'ssl': True},

However, when Django tries to connect to the database, I get this error

django.db.utils.OperationalError: (2026, ‘SSL connection error: The message received was unexpected or badly formatted’)

and I have not found any solutions, and any help would be greatly appreciated!

Best, Mads

Have you followed all the steps at Securing Connections for Client and Server - MariaDB Knowledge Base for enabling TLS?

Also, see the docs at MySQLdb User’s Guide — mysqlclient 1.2.4b4 documentation for what the ssl parameter may need to contain.

(Note: I’ve never used TLS with MySQL / MariaDB - I’m only echoing the information that I’m finding in the docs.)

1 Like

Hi Ken, thank you for your reply.

Indeed I have. I can connect fine over SSL/TLS from for example the official MariaDB python connector and execute queries.

Best, Mads