derek
derek

Reputation: 143

Python MySQL Connector: Can't connect to server with SSL

I'm trying to connect to a secured MySQL instance. I can connect to this server from this machine using SSL from other tools, including MySQL Workbench and MySQL Shell.

However, when I connect using the default connection arguments:

currdb = mysql.connector.connect(
    host="hostname",
    user="user",
    password="hunter2",
    port=3306 )

knowing that my server is configured with

require_secure_transport = 1

I get a server error:

mysql.connector.errors.DatabaseError: 3159 (HY000): Connections using insecure transport are prohibited while --require_secure_transport=ON.

Per the MySQL Connector documentation, the connector should attempt an SSL connection first, then fall back to an insecure connection. So evidently the SSL connection is failing with no explanation.

How do I troubleshoot the failed SSL connection when I know it's working for other tools on the same machine?

Python version: 3.7.2

MySQL Server version: 5.7.30

MySQL Connector version: 2.2.9

Upvotes: 2

Views: 3402

Answers (1)

HackLab
HackLab

Reputation: 539

I think you need to provide these flags:

ssl_ca File containing the SSL certificate authority.

ssl_cert File containing the SSL certificate file.

ssl_key File containing the SSL key.

Upvotes: 2

Related Questions