From 8ab51c65e7a008f7be3b931df6e8b98aef1f9652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Fri, 8 Mar 2024 20:46:36 +0000 Subject: [PATCH] ssl_params: use NULL instead of empty string #4466 If values in mysql_servers_ssl_params are empty strings, they needs to be passed as NULL arguments in mysql_ssl_set() and mysql_options() Closes #4466 --- lib/mysql_connection.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index e3430b02a7..e58d36c1c4 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -761,14 +761,16 @@ void MySQL_Connection::connect_start() { mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, mysql_thread___ssl_p2s_crlpath); } else { mysql_ssl_set(mysql, - ssl_params->ssl_key.c_str(), - ssl_params->ssl_cert.c_str(), - ssl_params->ssl_ca.c_str(), - ssl_params->ssl_capath.c_str(), - ssl_params->ssl_cipher.c_str() + ( ssl_params->ssl_key.length() > 0 ? ssl_params->ssl_key.c_str() : NULL ) , + ( ssl_params->ssl_cert.length() > 0 ? ssl_params->ssl_cert.c_str() : NULL ) , + ( ssl_params->ssl_ca.length() > 0 ? ssl_params->ssl_ca.c_str() : NULL ) , + ( ssl_params->ssl_capath.length() > 0 ? ssl_params->ssl_capath.c_str() : NULL ) , + ( ssl_params->ssl_cipher.length() > 0 ? ssl_params->ssl_cipher.c_str() : NULL ) ); - mysql_options(mysql, MYSQL_OPT_SSL_CRL, ssl_params->ssl_crl.c_str()); - mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, ssl_params->ssl_crlpath.c_str()); + mysql_options(mysql, MYSQL_OPT_SSL_CRL, + ( ssl_params->ssl_crl.length() > 0 ? ssl_params->ssl_crl.c_str() : NULL ) ); + mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, + ( ssl_params->ssl_crlpath.length() > 0 ? ssl_params->ssl_crlpath.c_str() : NULL ) ); } mysql_options(mysql, MARIADB_OPT_SSL_KEYLOG_CALLBACK, (void*)proxysql_keylog_write_line_callback); }