Python Forum
Thread Rating:
  • 2 Vote(s) - 1.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySQLdb and SSL
#1
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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020