From 3af79a556ebeecc0d0e148f644ecfe0c6c466af1 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 18 Dec 2022 18:01:08 +0000 Subject: [PATCH] Add SSL support to the mysql module. --- docs/conf/modules.conf.example | 2 +- src/modules/extra/m_mysql.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index 0794100d3..d02d2fbe2 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -1509,7 +1509,7 @@ # mysql is more complex than described here, see the docs for more # # info: https://docs.inspircd.org/3/modules/mysql # # -# +# #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Named modes module: Allows for the display and set/unset of channel diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 18076ecc3..c8457f3d5 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -341,6 +341,10 @@ class SQLConnection : public SQL::Provider unsigned int timeout = config->getDuration("timeout", 5, 1, 30); mysql_options(connection, MYSQL_OPT_CONNECT_TIMEOUT, &timeout); + // Enable SSL if requested. + unsigned int ssl = config->getBool("ssl") ? SSL_MODE_REQUIRED : SSL_MODE_PREFERRED; + mysql_options(connection, MYSQL_OPT_SSL_MODE, &ssl); + // Attempt to connect to the database. const std::string host = config->getString("host"); const std::string user = config->getString("user");