Attempting to connect to RDS MySQL instance through databases dict in settings.py file yields django.db.utils.OperationalError: (2026, 'SSL connection error: SSL_CTX_set_tmp_dh failed').
The error code is similar to django.db.utils.OperationalError: (2026, 'SSL connection error: SSL_CTX_set_tmp_dh failed'), so I tried using bin/mysql_ssl_rsa_setup to create default SSL and RSA files.
Setup (Similar to SSL connection error when connecting to RDS MySQL from Django)
- Standard Django application
- MySQL RDS instance with security group allowing connections from all IP addresses
- MySQL user is setup to allow connections from any host
- Amazon's pem has been downloaded and is specified in Django settings
Connection through cli works, as does connecting in interpreter through PyMySql.
The successful PyMySql connection and query look like this:
db = pymysql.connect(user=os.environ['DEV_DATABASE_USERNAME'],
password=os.environ['DEV_MYSQL_PASSWORD'],
host=os.environ['DEV_DATABASE_HOST'],
cursorclass=pymysql.cursors.DictCursor,
database='dev'),
ssl={'ssl':{'ca':<PATH TO CA CERT>}})
I've tried verifying that the path to the ca is absolute, which it is, and making sure that I'm not using python to attempt to build it, as in SSL connection error when connecting to RDS MySQL from Django.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'dev',
'USER': os.environ['DEV_DATABASE_USERNAME'],
'HOST': os.environ['DEV_DATABASE_HOST'],
'PASSWORD': os.environ['DEV_MYSQL_PASSWORD'],
'OPTIONS': {
'ssl': { 'ca': <PATH TO CA CERT> },
}
}
}