1

I have spent all day on this and cant figure it out. I have no problems connecting to the remote server using python and the mysql.connector but when i try using SSL I get the following error:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.4/dist-packages/mysql/connector/network.py", line 384, in switch_to_ssl
         self.sock.do_handshake()
      File "/usr/lib/python3.4/ssl.py", line 804, in do_handshake
         self._sslobj.do_handshake()
    ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:600)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "./mysql_test.py", line 25, in <module>
         con = mysql.connector.connect(**config);
      File "/usr/local/lib/python3.4/dist-packages/mysql/connector/__init__.py", line 179, in connect
         return MySQLConnection(*args, **kwargs)
      File "/usr/local/lib/python3.4/dist-packages/mysql/connector/connection.py", line 95, in __init__
         self.connect(**kwargs)
      File "/usr/local/lib/python3.4/dist-packages/mysql/connector/abstracts.py", line 719, in connect
         self._open_connection()
      File "/usr/local/lib/python3.4/dist-packages/mysql/connector/connection.py", line 210, in _open_connection
         self._ssl)
      File "/usr/local/lib/python3.4/dist-packages/mysql/connector/connection.py", line 134, in _do_auth
         self._socket.switch_to_ssl(**ssl_options)
      File "/usr/local/lib/python3.4/dist-packages/mysql/connector/network.py", line 390, in switch_to_ssl
         errno=2055, values=(self.get_address(), _strioerror(err)))
    mysql.connector.errors.InterfaceError: 2055: Lost connection to MySQL server at '192.168.1.10:3306', system error: 1 [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:600)
  • system spec both servers:
  • Debian 8.2
  • OpenSSL 1.0.1k 8 Jan 2015
  • mysql 5.7.X.
  • python3
  • pip3
  • mysql.connector = Connector/Python 2.1.3

I know the ssl connection works with php and cli mysql connections but i can't figure out how to get ssl to work properly. I have also tried to change the ssl protocol in the mysql.connector network.py source. I have also tried with and without use_pure flag. Any help is greatly appreciated.

the python source:

    import mysql.connector
     config = {
        'user' : 'uname', 
        'password' :'passwd', 
        'host' : '192.168.1.10',
        'database' : 'python',
        'ssl_ca' : '/etc/mysql/ssl/client/ca-cert.pem',
        'ssl_cert' : '/etc/mysql/ssl/client/client-cert.pem',
        'ssl_key' : '/etc/mysql/ssl/client/client-key.pem',
        'use_pure' : 'False'
    }
    con = mysql.connector.connect(**config);
    con.close();

1 Answer 1

1

I figured it out. Needed to remove the ssl_key and ssl_cert connection arguments, and only supply the ssl_ca and it works like a charm.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.