MXS-2811: Set TLS version with MARIADB_OPT_TLS_VERSION

The ssl_version values now also affect the TLS version used by the
connector.
This commit is contained in:
Markus Mäkelä 2020-03-05 00:23:21 +02:00
parent fda12c0cb2
commit 9eceeffc04
No known key found for this signature in database
GPG Key ID: 5CE746D557ACC499

View File

@ -47,6 +47,24 @@ MYSQL* mxs_mysql_real_connect(MYSQL* con, SERVER* server, const char* user, cons
const char* ssl_cert = ssl->cert.empty() ? nullptr : ssl->cert.c_str();
const char* ssl_ca = ssl->ca.empty() ? nullptr : ssl->ca.c_str();
mysql_ssl_set(con, ssl_key, ssl_cert, ssl_ca, NULL, NULL);
switch (ssl->version)
{
case SERVICE_TLS11:
mysql_optionsv(con, MARIADB_OPT_TLS_VERSION, "TLSv1.1,TLSv1.2,TLSv1.3");
break;
case SERVICE_TLS12:
mysql_optionsv(con, MARIADB_OPT_TLS_VERSION, "TLSv1.2,TLSv1.3");
break;
case SERVICE_TLS13:
mysql_optionsv(con, MARIADB_OPT_TLS_VERSION, "TLSv1.3");
break;
default:
break;
}
}
char yes = 1;