Skip to content

Add MySQL Connector/Python compatible SSL options. #903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

moriyoshi
Copy link
Contributor

@moriyoshi moriyoshi commented Nov 2, 2020

Background of the modification

This patch adds a bunch of connection arguments that are compatible with MySQL Connector/Python.
https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html

The rationale for the change is that SQLAlchemy propagates the parameters specified in the DSN's query to the constructor arguments as they are, which means it cannot build a structured parameter to give it to the underlying connection factory.
MySQL Connector/Python can take unstructued TLS parameters so it plays well with SQLAlchemy.

Details

This patch adds the following arguments:

  • ssl_ca: Path to the file that contains a PEM-formatted CA certificate
  • ssl_cert: Path to the file that contains a PEM-formatted client certificate
  • ssl_disabled: A boolean value that disables usage of TLS
  • ssl_key: Path to the file that contains a PEM-formatted private key for the client certificate
  • ssl_verify_cert: Set to true to check the validity of server certificates
  • ssl_verify_identity: Set to true to check the server's identity

This patch also introduces the following key for the dictionary that is supposed to be passed through ssl argument, which effectively closes #842.

  • verify_mode: none for ssl.CERT_NONE, optional for ssl.CERT_OPTIONAL and required for ssl.CERT_REQUIRED

@moriyoshi moriyoshi changed the title Add MySQL Connector/Python compatible SSL options. Also fixes #842. Add MySQL Connector/Python compatible SSL options. Nov 2, 2020
@methane methane enabled auto-merge (squash) January 2, 2021 08:09
@methane methane disabled auto-merge January 2, 2021 08:11
@methane methane merged commit aefbdbe into PyMySQL:master Jan 2, 2021
@methane methane mentioned this pull request Jan 8, 2021
3 tasks
@methane methane mentioned this pull request Oct 19, 2021
3 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for SSL/TLS verify_mode
2 participants