Python Forum

Full Version: MySQLdb and SSL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I've tried endlessly to make Python set up an SSL connection to an SQL server.
The Python script only initiates a regular unencrypted TCP/IP session, without SSL.
I verified this with Wireshark.

The script I use is the following:
#!/usr/bin/env python
import MySQLdb
ssl = {‘cert’: ‘/etc/mysql-ssl/client-cert.pem’, ‘key’: ‘/etc/mysql-ssl/client-key.pem’}
conn = MySQLdb.connect(host=x.x.x.x′, user=’ssluser’, passwd=’pass’, ssl=ssl)
cursor = conn.cursor()
cursor.execute(‘SHOW STATUS like “Ssl_cipher”‘)
print cursor.fetchone()

Now, when I configure the MySQL server to only allow the user to login with SSL, I cannot log in, and correctly refuses the connection.
When I allow unencrypted connections from that client, the connection is succesful.

I've searched the net for hours on end, but could not find a solution to this problem.

Again, the issue is that the python script does not start an TCP/IP connection using SSL.
I feel like I am missing something very basic...

Can someone point me in right direction?

I am using Ubuntu 16 as a host and Python version 2.7.12.

Thanks in advance.