From 0943e5d35407433d08cbfbd5af6838bd479864aa Mon Sep 17 00:00:00 2001 From: Gabriel Ngandu-Biseba Date: Fri, 6 Dec 2024 11:43:43 +0100 Subject: [PATCH] Remove unused config --- server/database.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/server/database.js b/server/database.js index a452bfed1..26a46cf2b 100644 --- a/server/database.js +++ b/server/database.js @@ -12,7 +12,6 @@ const { UptimeCalculator } = require("./uptime-calculator"); const dayjs = require("dayjs"); const { SimpleMigrationServer } = require("./utils/simple-migration-server"); const KumaColumnCompiler = require("./utils/knex/lib/dialects/mysql2/schema/mysql2-columncompiler"); -const { mariaDbSslCert, mariaDbUseSSL } = require("./config"); /** * Database & App Data Folder @@ -186,10 +185,18 @@ class Database { /** * @typedef {string|undefined} envString - * @param {{type: "sqlite"} | {type:envString, hostname:envString, port:envString, database:envString, username:envString, password:envString}} dbConfig the database configuration that should be written + * @param {{type: "sqlite"} | {type:envString, hostname:envString, port:envString, database:envString, username:envString, password:envString, caFilePath:envString}} dbConfig the database configuration that should be written * @returns {void} */ static writeDBConfig(dbConfig) { + // Move CA file to the data directory + if (dbConfig.caFilePath) { + const dataCaFilePath = path.join(Database.dataDir, "mariadb-ca.pem"); + fs.renameSync(dbConfig.caFilePath, dataCaFilePath); + dbConfig.caFilePath = dataCaFilePath; + dbConfig.ssl = undefined; + dbConfig.caFile = undefined; + } fs.writeFileSync(path.join(Database.dataDir, "db-config.json"), JSON.stringify(dbConfig, null, 4)); } @@ -263,8 +270,8 @@ class Database { let sslConfig = null; let serverCa = undefined; - if (mariaDbUseSSL === true) { - serverCa = [ fs.readFileSync(mariaDbSslCert, "utf8") ]; + if (dbConfig.caFilePath) { + serverCa = [ fs.readFileSync(dbConfig.caFilePath, "utf8") ]; sslConfig = { rejectUnauthorized: true, ca: serverCa @@ -290,8 +297,9 @@ class Database { user: dbConfig.username, password: dbConfig.password, database: dbConfig.dbName, - timezone: "Z", ssl: sslConfig, + timezone: "Z", + //ssl: sslConfig, typeCast: function (field, next) { if (field.type === "DATETIME") { // Do not perform timezone conversion