Getting empty 'Ssl_cipher' with MySQLdb SSL connection to Amazon RDS
Question: I've just spent a week on the problems recorded in this question: [Why does
the CA information need to be in a tuple for
MySQLdb?](http://stackoverflow.com/questions/21315427/why-does-the-ca-
information-need-to-be-in-a-tuple-for-mysqldb)

Have now boiled it down to one problem. Here's a script that connects to the
MySQL server I have on Amazon RDS:

    
    
    #! /usr/bin/env python
    import MySQLdb
    ssl = ({'ca': '/home/James/Downloads/mysql-ssl-ca-cert-copy.pem'},)
    conn = MySQLdb.connect(host='db.doopdoop.eu-west-n.rds.amazonaws.com', user='user', passwd='pass', ssl=ssl)
    cursor = conn.cursor()
    cursor.execute("SHOW STATUS LIKE 'Ssl_Cipher'")
    print cursor.fetchone()
    

This gives me back `('Ssl_cipher', '')`, which I gather means the connection
is not encrypted. Have also tried this using Django's `manage.py shell`
function, and got the same result. Why, then, am I getting no exceptions? Data
is flowing, certainly, but apparently the security is just being ignored. Any
help on where I'm going wrong here would be appreciated.

I have tried updating MySQL-Python to 1.2.5 with no success.


Answer: Possible workaround for your issue: Use a default file. It will look something
like this:

    
    
    [mysql]
    host = db.doopdoop.eu-west-n.rds.amazonaws.com
    user = user
    password = pass
    ssl-ca = /home/James/Downloads/mysql-ssl-ca-cert-copy.pem
    

Then change your connect() call to:

    
    
    conn = MySQLdb.connect(read_default_file=options_path)
    

where options_path is the path to the file above. This also keeps
authentication data out of your code.

Django settings will look like this:

    
    
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'OPTIONS': {
                'read_default_file': '/path/to/my.cnf',
            },
        }
    }
    

Ref: <https://docs.djangoproject.com/en/dev/ref/databases/#connecting-to-the-
database>

