Skip to content

Commit

Permalink
Add dbConnect option "use_ssl" for MySQL (PR multitheftauto#3307)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lpsd authored Feb 5, 2024
1 parent 721c2b6 commit e647676
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Server/dbconmy/CDatabaseConnectionMySql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class CDatabaseConnectionMySql : public CDatabaseConnection
bool m_bInAutomaticTransaction;
CTickCount m_AutomaticTransactionStartTime;
int m_bMultipleStatements;
int m_bUseSSL;
};

///////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit e647676

Please sign in to comment.