mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-17 05:29:43 -04:00
Added the ability to use TLS when connecting to a database. (#24348)
* Added the ability to use TLS when connecting to a database. * Trying to kickstart CI checks * Revert the kickstart change Co-authored-by: myuzhobcplidtkieno <myuzhobcplidtkieno@github.com> Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
This commit is contained in:
committed by
GitHub
parent
dcd2ffdaf4
commit
ae553f8966
@@ -34,7 +34,7 @@ MySQLConnectionInfo::MySQLConnectionInfo(std::string const& infoString)
|
||||
{
|
||||
Tokenizer tokens(infoString, ';');
|
||||
|
||||
if (tokens.size() != 5)
|
||||
if (tokens.size() != 5 && tokens.size() != 6)
|
||||
return;
|
||||
|
||||
uint8 i = 0;
|
||||
@@ -44,6 +44,9 @@ MySQLConnectionInfo::MySQLConnectionInfo(std::string const& infoString)
|
||||
user.assign(tokens[i++]);
|
||||
password.assign(tokens[i++]);
|
||||
database.assign(tokens[i++]);
|
||||
|
||||
if (tokens.size() == 6)
|
||||
ssl.assign(tokens[i++]);
|
||||
}
|
||||
|
||||
MySQLConnection::MySQLConnection(MySQLConnectionInfo& connInfo) :
|
||||
@@ -129,6 +132,16 @@ uint32 MySQLConnection::Open()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_connectionInfo.ssl != "")
|
||||
{
|
||||
my_bool opt_use_ssl = false;
|
||||
if (m_connectionInfo.ssl == "ssl")
|
||||
{
|
||||
opt_use_ssl = true;
|
||||
}
|
||||
mysql_options(mysqlInit, MYSQL_OPT_SSL_ENFORCE, (char const*)&opt_use_ssl);
|
||||
}
|
||||
|
||||
m_Mysql = reinterpret_cast<MySQLHandle*>(mysql_real_connect(mysqlInit, m_connectionInfo.host.c_str(), m_connectionInfo.user.c_str(),
|
||||
m_connectionInfo.password.c_str(), m_connectionInfo.database.c_str(), port, unix_socket, 0));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user