From c8983886f2612e4101c193b68cfd612cb1be9b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 31 Aug 2020 10:15:48 +0300 Subject: [PATCH] Use TLS with the Connection class This fixes the problem where an encrypted connection would not be created even though the option for it was there. Also made it configurable outside of the constructor to make it easier to use in tests. --- .../maxtest/include/maxtest/mariadb_func.h | 14 ++++---------- system-test/maxtest/src/mariadb_func.cc | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/system-test/maxtest/include/maxtest/mariadb_func.h b/system-test/maxtest/include/maxtest/mariadb_func.h index 8a2a3d08d..428ac0373 100644 --- a/system-test/maxtest/include/maxtest/mariadb_func.h +++ b/system-test/maxtest/include/maxtest/mariadb_func.h @@ -305,19 +305,13 @@ public: mysql_close(m_conn); } - bool connect() + void ssl(bool value) { - mysql_close(m_conn); - m_conn = mysql_init(NULL); - - // MXS-2568: This fixes mxs1828_double_local_infile - mysql_optionsv(m_conn, MYSQL_OPT_LOCAL_INFILE, (void*)"1"); - - return mysql_real_connect(m_conn, m_host.c_str(), m_user.c_str(), m_pw.c_str(), m_db.c_str(), m_port, - NULL, CLIENT_MULTI_STATEMENTS) - && mysql_errno(m_conn) == 0; + m_ssl = value; } + bool connect(); + void disconnect() { mysql_close(m_conn); diff --git a/system-test/maxtest/src/mariadb_func.cc b/system-test/maxtest/src/mariadb_func.cc index af0cb8148..9c2cd4054 100644 --- a/system-test/maxtest/src/mariadb_func.cc +++ b/system-test/maxtest/src/mariadb_func.cc @@ -592,3 +592,21 @@ int get_int_version(std::string version) str >> major >> dot >> minor >> dot >> patch; return major * 10000 + minor * 100 + patch; } + +bool Connection::connect() +{ + mysql_close(m_conn); + m_conn = mysql_init(NULL); + + // MXS-2568: This fixes mxs1828_double_local_infile + mysql_optionsv(m_conn, MYSQL_OPT_LOCAL_INFILE, (void*)"1"); + + if (m_ssl) + { + set_ssl(m_conn); + } + + return mysql_real_connect(m_conn, m_host.c_str(), m_user.c_str(), m_pw.c_str(), m_db.c_str(), m_port, + NULL, CLIENT_MULTI_STATEMENTS) + && mysql_errno(m_conn) == 0; +}