Skip to content

Commit 82bc265

Browse files
committed
mysql: disable implicit TLS enforcement for non-SSL servers
1 parent 465f7ad commit 82bc265

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/CConnection.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "mysql.hpp"
22

3+
#include <cstdlib>
4+
35
#include "CQuery.hpp"
46
#include "CConnection.hpp"
57
#include "CDispatcher.hpp"
@@ -30,6 +32,21 @@ CConnection::CConnection(const char *host, const char *user, const char *passw,
3032
return;
3133
}
3234

35+
// Keep non-TLS servers compatible by default. Some MariaDB client builds
36+
// enable strict peer verification by default, which implicitly forces SSL.
37+
// This aligns runtime behavior with legacy SA:MP/open.mp deployments.
38+
#if defined(__linux__)
39+
setenv("MARIADB_TLS_DISABLE_PEER_VERIFICATION", "1", 0);
40+
#endif
41+
#if defined(MYSQL_OPT_SSL_ENFORCE)
42+
my_bool ssl_enforce = 0;
43+
mysql_options(m_Connection, MYSQL_OPT_SSL_ENFORCE, &ssl_enforce);
44+
#endif
45+
#if defined(MYSQL_OPT_SSL_VERIFY_SERVER_CERT)
46+
my_bool ssl_verify_server_cert = 0;
47+
mysql_options(m_Connection, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &ssl_verify_server_cert);
48+
#endif
49+
3350
if (options->GetOption<bool>(COptions::Type::SSL_ENABLE))
3451
{
3552
string

0 commit comments

Comments
 (0)