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.
This commit is contained in:
parent
724074a178
commit
c8983886f2
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user