Added selfsigned cert support to mysql/mariadb ssl

Noah Zalev committed Apr 30, 2021 at 23:16 UTC dc75589bd30f05be81f148ae6ea7b0608ddba2ab
2 files changed +29 -2
db.js
+9
@@ -446,6 +446,15 @@ module.exports.CreateDB = function (parent, func) {
446 var connectionObject = Clone(connectinArgs);
447 delete connectionObject.database;
448
449 + try {
450 + if (connectinArgs.ssl.cacertpath) { connectionObject.ssl.ca = [require('fs').readFileSync(connectinArgs.ssl.cacertpath, 'utf8')]; }
451 + if (connectinArgs.ssl.clientcertpath) { connectionObject.ssl.cert = [require('fs').readFileSync(connectinArgs.ssl.clientcertpath, 'utf8')]; }
452 + if (connectinArgs.ssl.clientkeypath) { connectionObject.ssl.key = [require('fs').readFileSync(connectinArgs.ssl.clientkeypath, 'utf8')]; }
453 + } catch (ex) {
454 + console.log('Error loading SQL Connector certificate: ' + ex);
455 + process.exit();
456 + }
457 +
458 if (parent.args.mariadb) {
459 // Use MariaDB
460 obj.databaseType = 4;
meshcentral-config-schema.json
+20 -2
@@ -21,7 +21,16 @@
21 "port": { "type": "number", "description": "MariaDB port number" },
22 "password": { "type": "string", "description": "MariaDB password" },
23 "connectionLimit": { "type": "number", "description": "MariaDB connection limit" },
24 - "database": { "type": "string", "default": "meshcentral", "description": "Name of MariaDB database used" }
24 + "database": { "type": "string", "default": "meshcentral", "description": "Name of MariaDB database used" },
25 + "ssl": {
26 + "type": "object",
27 + "description": "SSL Options. Set to true (boolean) for default options.",
28 + "properties": {
29 + "caCertPath": { "type": "string", "description": "Absolute path to the CA certificate. Required for self-signed certificates" },
30 + "clientCertPath": { "type": "string", "description": "Absolute path to the client certificate. Required for two-way SSL Authentication" },
31 + "clientKeyPath": { "type": "string", "description": "Absolute path to the client key. Required for two-way SSL Authentication" }
32 + }
33 + }
34 }
35 },
36 "mySQL": {
@@ -32,7 +41,16 @@
41 "port": { "type": "number", "description": "MySQL port number" },
42 "user": { "type": "string", "description": "MySQL username" },
43 "password": { "type": "string", "description": "MySQL password" },
35 - "database": { "type": "string", "default": "meshcentral", "description": "Name of MySQL database used" }
44 + "database": { "type": "string", "default": "meshcentral", "description": "Name of MySQL database used" },
45 + "ssl": {
46 + "type": "object",
47 + "description": "SSL Options. Set to true (boolean) for default options.",
48 + "properties": {
49 + "caCertPath": { "type": "string", "description": "Absolute path to the CA certificate. Required for self-signed certificates" },
50 + "clientCertPath": { "type": "string", "description": "Absolute path to the client certificate. Required for two-way SSL Authentication" },
51 + "clientKeyPath": { "type": "string", "description": "Absolute path to the client key. Required for two-way SSL Authentication" }
52 + }
53 + }
54 }
55 },
56 "WANonly": { "type": "boolean", "default": false, "description": "When enabled, only MeshCentral WAN features are enabled and agents will connect to the server using a well known DNS name." },