mysqlclient icon indicating copy to clipboard operation
mysqlclient copied to clipboard

Add ability to customize ssl mode settings

Open thereisnosun opened this issue 4 years ago • 2 comments

At the moment mysql-client have following defined:

#if ((MYSQL_VERSION_ID >= 50555 && MYSQL_VERSION_ID <= 50599) || \
(MYSQL_VERSION_ID >= 50636 && MYSQL_VERSION_ID <= 50699) || \
(MYSQL_VERSION_ID >= 50711 && MYSQL_VERSION_ID <= 50799) || \
(MYSQL_VERSION_ID >= 80000)) && \
!defined(MARIADB_BASE_VERSION) && !defined(MARIADB_VERSION_ID)
#define HAVE_ENUM_MYSQL_OPT_SSL_MODE
#endif

meaning, that it will accept ssl_mode argument only in the case of MySQL, but not in the case of MariaDB. This is pretty odd, because even though MariaDB does not support the sophisticated ssl_mode argument as MySQL does, it still allows some SSL tweaking:

  • MYSQL_OPT_SSL_VERIFY_SERVER_CERT: Enables (or disables) server certificate verification

  • MYSQL_OPT_SSL_ENFORCE: Whether to force TLS. This enables TLS with the default system settings. It does not prevent the connection from being created if the server does not support TLS.

See more: https://mariadb.com/kb/en/mysql_optionsv/

So, seems logical for me to do is to allow the same ssl_mode option for MariaDB, but inside of mysqlclient handle it accordingly. So for the lib user, the interface would remain the same.

thereisnosun avatar Jan 13 '21 10:01 thereisnosun

I already provided the PR, which is fixing the issue described above: https://github.com/PyMySQL/mysqlclient/pull/475 Let's discuss the change and make mysqlclient even better :)

thereisnosun avatar Jan 13 '21 10:01 thereisnosun

ssl_mode is already present in the code - see https://github.com/PyMySQL/mysqlclient/blob/main/doc/user_guide.rst#functions-and-attributes.

The documentation in https://mysqlclient.readthedocs.io/ is outdated and hence missing this information (#552)

matusvalo avatar Aug 12 '22 14:08 matusvalo