Remove SSL directory

This commit is contained in:
Benjamin Toby 2024-11-08 20:15:37 +01:00
parent b9d9a584b3
commit b337e5748f
6 changed files with 17 additions and 48 deletions

4
.gitignore vendored
View File

@ -143,3 +143,7 @@ test/
# .npmrc
/dump
ssl
ssl*
*ssl
/ssl

View File

@ -21,8 +21,7 @@
const fs = require("fs");
const mysql = require("mysql");
const path = require("path");
const SSL_PATH = path.resolve(__dirname, "../../../ssl");
const grabDbSSL = require("../../../package-shared/utils/backend/grabDbSSL");
const connection = mysql.createConnection({
host: process.env.DSQL_HOST,
@ -34,21 +33,7 @@ const connection = mysql.createConnection({
? parseInt(process.env.DSQL_PORT)
: undefined,
timeout: 5000,
ssl: {
ca: fs.readFileSync(`${SSL_PATH}/ca-cert.pem`),
},
// ssl: {
// ca: (() => {
// try {
// if (process.env.DSQL_SSL_CA_PATH) {
// return fs.readFileSync(process.env.DSQL_SSL_CA_PATH);
// }
// return undefined;
// } catch (error) {
// return undefined;
// }
// })(),
// },
ssl: grabDbSSL(),
});
//////////////////////////////////////////////////////////////////////////////////

View File

@ -3,8 +3,7 @@
const fs = require("fs");
const mysql = require("mysql");
const path = require("path");
const SSL_PATH = path.resolve(__dirname, "../../../ssl");
const grabDbSSL = require("../../../package-shared/utils/backend/grabDbSSL");
const connection = mysql.createConnection({
host: process.env.DSQL_HOST,
@ -15,9 +14,7 @@ const connection = mysql.createConnection({
? parseInt(process.env.DSQL_PORT)
: undefined,
timeout: 5000,
ssl: {
ca: fs.readFileSync(`${SSL_PATH}/ca-cert.pem`),
},
ssl: grabDbSSL(),
});
/**

View File

@ -7,12 +7,17 @@ const fs = require("fs");
*/
module.exports = function grabDbSSL() {
const SSL_DIR = process.env.DSQL_SSL_DIR;
if (!SSL_DIR?.match(/./)) return undefined;
if (!SSL_DIR?.match(/./)) {
console.log(
"No SSL certificate provided. Query will run in normal mode. To add SSL add an env path dir `DSQL_SSL_DIR` with a file named `ca-cert.pem`"
);
return undefined;
}
const caFilePath = `${SSL_DIR}/ca-cert.pem`;
if (!fs.existsSync(caFilePath)) {
console.log(`${caFilePath} does not exist`);
return undefined;
}

View File

@ -1,6 +1,6 @@
{
"name": "datasquirel",
"version": "2.5.0",
"version": "2.5.1",
"description": "Cloud-based SQL data management tool",
"main": "index.js",
"bin": {
@ -9,7 +9,7 @@
},
"scripts": {
"compile": "tsc --declaration --allowJs --emitDeclarationOnly --resolveJsonModule index.js",
"compile-tsc": "rm -rf dist && tsc --declaration --allowJs --outDir dist --emitDeclarationOnly --resolveJsonModule index.js && cat ./dist/index.d.ts > ./index.d.ts"
"compile:full": "rm -rf dist && tsc --declaration --allowJs --outDir dist --emitDeclarationOnly --resolveJsonModule index.js && cat ./dist/index.d.ts > ./index.d.ts"
},
"repository": {
"type": "git",

View File

@ -1,22 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDnTCCAoWgAwIBAgIUVruYX02DdRIrbHXkrlz1LkntCYowDQYJKoZIhvcNAQEL
BQAwXTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEWMBQGA1UEAwwNTWFyaWFEQiBhZG1p
bjAgFw0yNDAxMDkxNTAxMjFaGA8zMDIzMDUxMjE1MDEyMVowXTELMAkGA1UEBhMC
QVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdp
dHMgUHR5IEx0ZDEWMBQGA1UEAwwNTWFyaWFEQiBhZG1pbjCCASIwDQYJKoZIhvcN
AQEBBQADggEPADCCAQoCggEBAMIpgpOT66kqbr4AS3BKlEFY6U+OtGuWmC2RPLYq
moZ3WXNrgqL4ymhe/mdIJgr4PPjVnuwgDElRw0v1Vrnf9Gg4Dy1zWIXIGKxF4Cu9
UGK546xtVnn8f7DPjdPKSmZN0iZh3Z+1Pu/P3a62dJ30c+rcUw/pPq2aGWNY/iWo
MtCVxTjTl92+gR1tRfXw88xHW/v4ly+GeijC6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