Skip to content

Commit 9028b45

Browse files
committed
ssl_mode="REQUIRED" disables verification of the server certificate by default.
mariadb connector/c changed the default value of MYSQL_OPT_SSL_VERIFY_SERVER_CERT to 1. this change makes it can be disabled by ssl_mode="DISABLED", "PREFERRED", and "REQUIRED".
1 parent 611adf1 commit 9028b45

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/MySQLdb/_mysql.c

+7
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,13 @@ _mysql_ConnectionObject_Initialize(
558558
if (ssl_mode_num >= SSLMODE_VERIFY_CA) {
559559
mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (void *)&enforce_tls);
560560
}
561+
else {
562+
// mariadb-connector-c changed the default value of MYSQL_OPT_SSL_VERIFY_SERVER_CERT to 1.
563+
// https://github.com/mariadb-corporation/mariadb-connector-c/commit/8dffd56936df3d03eeccf47904773860a0cdeb57
564+
// for users don't want to verify the server certificate, we provide an option to disable it.
565+
my_bool my_false = 0;
566+
mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (void *)&my_false);
567+
}
561568
#endif
562569
}
563570

0 commit comments

Comments
 (0)