Add SSL support to the mysql module.

This commit is contained in:
Sadie Powell 2022-12-18 18:01:08 +00:00
parent 3ac6d92316
commit 3af79a556e
2 changed files with 5 additions and 1 deletions

View File

@ -1509,7 +1509,7 @@
# mysql is more complex than described here, see the docs for more #
# info: https://docs.inspircd.org/3/modules/mysql #
#
#<database module="mysql" name="mydb" user="myuser" pass="mypass" host="localhost" id="my_database2">
#<database module="mysql" name="mydb" user="myuser" pass="mypass" host="localhost" id="my_database2" ssl="no">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Named modes module: Allows for the display and set/unset of channel

View File

@ -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");