I am trying to connect to my MariaDB with SSL enabled. On my old installation (Kubuntu 19.10) this worked. With the new installation (also new PC: Xubuntu 20.04) I get this error message:
ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:1108)
Here are my installation details:
Old installation: python 3.7.5, pymysql 0.9.3, ssl.OPENSSL_VERSION = 1.1.1c 28 May 2019
New installation: python 3.8.2, pymysql 0.9.3, ssl.OPENSSL_VERSION = 1.1.1f 31 Mar 2020
I have compiled python 3.7.5 on my new PC -> I still get the error message.
I have compiled python with a different SSL version:
this works: python 3.7.5, ssl.OPENSSL_VERSION = OpenSSL 1.1.0m-dev xx XXX xxxx
this works: python 3.7.5, ssl.OPENSSL_VERSION = OpenSSL 1.1.1h-dev xx XXX xxxx
this works: python 3.8.2, ssl.OPENSSL_VERSION = OpenSSL 1.1.1h-dev xx XXX xxxx
This is my test script:
import os
import pymysql
#pymysql.connections.DEBUG = True
#pymysql._auth.DEBUG = True
host = "127.0.0.1"
port = 3306
ca = os.path.expanduser("~/ca-cert.pem")
ssl = {'ca': ca, 'check_hostname': False}
user = 'user'
passwd = 'passwd'
def test_ssl():
con = pymysql.connect(user=user, password=passwd, host=host, port=port, ssl=ssl)
con.close()
test_ssl()
The ca-cert I have created like this:
openssl genrsa 2048 > ca-key.pem
openssl req -new -x509 -nodes -days 3600 -key ca-key.pem -out ca-cert.pem
It seems, like the one specific version of openSSL does not work together with PyMySQL. It could be an error with the Xubuntu compilation. Or it could be the specific version (1.1.1f). But I do not know, how to compile this version myself.