From e6476767a9b6848467f0d123830dd2f90bd4442d Mon Sep 17 00:00:00 2001 From: lopsi <40902730+Lpsd@users.noreply.github.com> Date: Mon, 5 Feb 2024 18:29:53 +0000 Subject: [PATCH] Add dbConnect option "use_ssl" for MySQL (PR #3307) --- Server/dbconmy/CDatabaseConnectionMySql.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Server/dbconmy/CDatabaseConnectionMySql.cpp b/Server/dbconmy/CDatabaseConnectionMySql.cpp index 1262e39c0a..c1777b8aa2 100644 --- a/Server/dbconmy/CDatabaseConnectionMySql.cpp +++ b/Server/dbconmy/CDatabaseConnectionMySql.cpp @@ -57,6 +57,7 @@ class CDatabaseConnectionMySql : public CDatabaseConnection bool m_bInAutomaticTransaction; CTickCount m_AutomaticTransactionStartTime; int m_bMultipleStatements; + int m_bUseSSL; }; /////////////////////////////////////////////////////////////// @@ -85,6 +86,7 @@ CDatabaseConnectionMySql::CDatabaseConnectionMySql(CDatabaseType* pManager, cons optionsMap.Get("autoreconnect", m_bAutomaticReconnect, 1); optionsMap.Get("batch", m_bAutomaticTransactionsEnabled, 1); optionsMap.Get("multi_statements", m_bMultipleStatements, 0); + optionsMap.Get("use_ssl", m_bUseSSL, 0); SString strHostname; SString strDatabaseName; @@ -106,7 +108,9 @@ CDatabaseConnectionMySql::CDatabaseConnectionMySql(CDatabaseType* pManager, cons if (m_handle) { bool reconnect = m_bAutomaticReconnect; + uint const ssl_mode = m_bUseSSL ? SSL_MODE_REQUIRED : SSL_MODE_DISABLED; mysql_options(m_handle, MYSQL_OPT_RECONNECT, &reconnect); + mysql_options(m_handle, MYSQL_OPT_SSL_MODE, &ssl_mode); if (!strCharset.empty()) mysql_options(m_handle, MYSQL_SET_CHARSET_NAME, strCharset); if (m_bMultipleStatements)