Refactor SSL

This commit is contained in:
Benjamin Toby
2024-11-06 13:57:20 +01:00
parent eb341a7845
commit 83d261362f
316 changed files with 541 additions and 4615 deletions
+26 -6
View File
@@ -8,10 +8,8 @@ exports.modules = {
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
const mysql = __webpack_require__(2261);
const SSL_DIR = process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../../ssl");
const grabDbSSL = __webpack_require__(4824);
const MASTER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
@@ -20,9 +18,7 @@ const MASTER = mysql({
database: process.env.DSQL_DB_NAME,
port: process.env.DSQL_DB_PORT ? Number(process.env.DSQL_DB_PORT) : undefined,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
/**
@@ -49,6 +45,30 @@ async function DB_HANDLER(...args) {
module.exports = DB_HANDLER;
/***/ }),
/***/ 4824:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
/**
* @returns {string | (import("tls").SecureContextOptions & { rejectUnauthorized?: boolean | undefined;}) | undefined}
*/ module.exports = function grabDbSSL() {
const SSL_DIR = process.env.DSQL_SSL_DIR;
if (!SSL_DIR?.match(/./)) return undefined;
const caFilePath = `${SSL_DIR}/ca-cert.pem`;
if (!fs.existsSync(caFilePath)) {
console.log(`${caFilePath} does not exist`);
return undefined;
}
return {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
};
};
/***/ })
};
+26 -5
View File
@@ -101,8 +101,7 @@ exports.modules = {
const fs = __webpack_require__(7147);
const serverError = __webpack_require__(7023);
const mysql = __webpack_require__(2261);
const path = __webpack_require__(1017);
const SSL_DIR = process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../ssl");
const grabDbSSL = __webpack_require__(3260);
const connection = mysql({
config: {
host: process.env.DSQL_DB_HOST,
@@ -110,9 +109,7 @@ const connection = mysql({
password: process.env.DSQL_DB_PASSWORD,
database: process.env.DSQL_DB_NAME,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
/**
@@ -167,6 +164,30 @@ const connection = mysql({
};
/***/ }),
/***/ 3260:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
/**
* @returns {string | (import("tls").SecureContextOptions & { rejectUnauthorized?: boolean | undefined;}) | undefined}
*/ module.exports = function grabDbSSL() {
const SSL_DIR = process.env.DSQL_SSL_DIR;
if (!SSL_DIR?.match(/./)) return undefined;
const caFilePath = `${SSL_DIR}/ca-cert.pem`;
if (!fs.existsSync(caFilePath)) {
console.log(`${caFilePath} does not exist`);
return undefined;
}
return {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
};
};
/***/ })
};
+4 -10
View File
@@ -11,16 +11,14 @@ exports.modules = {
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
const mysql = __webpack_require__(2261);
const SSL_DIR = process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../../ssl");
const grabDbSSL = __webpack_require__(4824);
let DSQL_USER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_READ_ONLY_USERNAME,
password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
/**
@@ -42,9 +40,7 @@ let DSQL_USER = mysql({
user: process.env.DSQL_DB_FULL_ACCESS_USERNAME,
password: process.env.DSQL_DB_FULL_ACCESS_PASSWORD,
database: database,
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
} else {
@@ -54,9 +50,7 @@ let DSQL_USER = mysql({
user: process.env.DSQL_DB_READ_ONLY_USERNAME,
password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
database: database,
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
}
+2 -6
View File
@@ -859,19 +859,15 @@ const NO_DB_HANDLER = __webpack_require__(2020);
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
const mysql = __webpack_require__(2261);
const SSL_DIR = process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../../ssl");
const grabDbSSL = __webpack_require__(3260);
let NO_DB = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_USERNAME,
password: process.env.DSQL_DB_PASSWORD,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
/**
+26 -6
View File
@@ -39,10 +39,8 @@ module.exports = decrypt;
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
const mysql = __webpack_require__(2261);
const SSL_DIR = process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../../ssl");
const grabDbSSL = __webpack_require__(3260);
const MASTER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
@@ -51,9 +49,7 @@ const MASTER = mysql({
database: process.env.DSQL_DB_NAME,
port: process.env.DSQL_DB_PORT ? Number(process.env.DSQL_DB_PORT) : undefined,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
/**
@@ -80,6 +76,30 @@ async function DB_HANDLER(...args) {
module.exports = DB_HANDLER;
/***/ }),
/***/ 3260:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
/**
* @returns {string | (import("tls").SecureContextOptions & { rejectUnauthorized?: boolean | undefined;}) | undefined}
*/ module.exports = function grabDbSSL() {
const SSL_DIR = process.env.DSQL_SSL_DIR;
if (!SSL_DIR?.match(/./)) return undefined;
const caFilePath = `${SSL_DIR}/ca-cert.pem`;
if (!fs.existsSync(caFilePath)) {
console.log(`${caFilePath} does not exist`);
return undefined;
}
return {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
};
};
/***/ })
};
+2 -6
View File
@@ -8,19 +8,15 @@ exports.modules = {
// @ts-check
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
const mysql = __webpack_require__(2261);
const SSL_DIR = process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../../ssl");
const grabDbSSL = __webpack_require__(4824);
let NO_DB = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_USERNAME,
password: process.env.DSQL_DB_PASSWORD,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
/**
+4 -10
View File
@@ -11,16 +11,14 @@ exports.modules = {
const fs = __webpack_require__(7147);
const path = __webpack_require__(1017);
const mysql = __webpack_require__(2261);
const SSL_DIR = process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../../ssl");
const grabDbSSL = __webpack_require__(3260);
let DSQL_USER = mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_READ_ONLY_USERNAME,
password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
charset: "utf8mb4",
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
/**
@@ -42,9 +40,7 @@ let DSQL_USER = mysql({
user: process.env.DSQL_DB_FULL_ACCESS_USERNAME,
password: process.env.DSQL_DB_FULL_ACCESS_PASSWORD,
database: database,
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
} else {
@@ -54,9 +50,7 @@ let DSQL_USER = mysql({
user: process.env.DSQL_DB_READ_ONLY_USERNAME,
password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
database: database,
ssl: {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
}
ssl: grabDbSSL()
}
});
}