Skip to content

Commit e647676

Browse files
authored
Add dbConnect option "use_ssl" for MySQL (PR #3307)
1 parent 721c2b6 commit e647676

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Server/dbconmy/CDatabaseConnectionMySql.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class CDatabaseConnectionMySql : public CDatabaseConnection
5757
bool m_bInAutomaticTransaction;
5858
CTickCount m_AutomaticTransactionStartTime;
5959
int m_bMultipleStatements;
60+
int m_bUseSSL;
6061
};
6162

6263
///////////////////////////////////////////////////////////////
@@ -85,6 +86,7 @@ CDatabaseConnectionMySql::CDatabaseConnectionMySql(CDatabaseType* pManager, cons
8586
optionsMap.Get("autoreconnect", m_bAutomaticReconnect, 1);
8687
optionsMap.Get("batch", m_bAutomaticTransactionsEnabled, 1);
8788
optionsMap.Get("multi_statements", m_bMultipleStatements, 0);
89+
optionsMap.Get("use_ssl", m_bUseSSL, 0);
8890

8991
SString strHostname;
9092
SString strDatabaseName;
@@ -106,7 +108,9 @@ CDatabaseConnectionMySql::CDatabaseConnectionMySql(CDatabaseType* pManager, cons
106108
if (m_handle)
107109
{
108110
bool reconnect = m_bAutomaticReconnect;
111+
uint const ssl_mode = m_bUseSSL ? SSL_MODE_REQUIRED : SSL_MODE_DISABLED;
109112
mysql_options(m_handle, MYSQL_OPT_RECONNECT, &reconnect);
113+
mysql_options(m_handle, MYSQL_OPT_SSL_MODE, &ssl_mode);
110114
if (!strCharset.empty())
111115
mysql_options(m_handle, MYSQL_SET_CHARSET_NAME, strCharset);
112116
if (m_bMultipleStatements)

0 commit comments

Comments
 (0)