GreenLockv3 fixes
Ylian Saint-Hilaire committed
Nov 15, 2019 at 17:55 UTC
b45b60fb134e50fd4096eaaae66b6fe1521397b5
8 files changed
+29
-25
.greenlockrc
new
+3
@@ -0,0 +1,3 @@
1
+{
2
+ "manager": "C:\\Users\\Default.DESKTOP-M9I88C9\\Desktop\\AmtWebApp\\meshcentral\\letsencrypt.js"
3
+}
\ No newline at end of file
letsEncrypt.js
+9
-15
@@ -14,7 +14,7 @@
14
/*jshint esversion: 6 */
15
'use strict';
16
17
-module.exports.CreateLetsEncrypt = function(parent) {
17
+module.exports.CreateLetsEncrypt = function (parent) {
18
try {
19
parent.debug('cert', "Initializing Let's Encrypt support");
20
@@ -67,7 +67,7 @@ module.exports.CreateLetsEncrypt = function(parent) {
67
// Latest NodeJS
68
maintainerEmail = pkg.author.email;
69
}
70
-
70
+
71
// Create the main GreenLock code module.
72
var greenlockargs = {
73
parent: obj,
@@ -110,16 +110,10 @@ module.exports.CreateLetsEncrypt = function(parent) {
110
obj.parent.config.letsencrypt.names.map(function (s) { return s.trim(); }); // Trim each name
111
if ((typeof obj.parent.config.letsencrypt.names != 'object') || (obj.parent.config.letsencrypt.names.length == null)) { console.log("ERROR: Let's Encrypt names must be an array in config.json."); func(certs); return; }
112
obj.leDomains = obj.parent.config.letsencrypt.names;
113
- obj.leDomains.sort(); // Sort the array so it's always going to be in the same order.
113
}
114
116
- // Get altnames
117
- obj.altnames = [];
118
- obj.servername = certs.CommonName;
119
- for (var i in obj.leDomains) { if (obj.leDomains[i] != certs.CommonName) { obj.altnames.push(obj.leDomains[i]); } }
120
-
115
// Get the Let's Encrypt certificate from our own storage
122
- obj.le.get({ servername: certs.CommonName })
116
+ obj.le.get({ servername: obj.leDomains[0] })
117
.then(function (results) {
118
// If we already have real certificates, use them.
119
if (results) {
@@ -156,14 +150,14 @@ module.exports.CreateLetsEncrypt = function(parent) {
150
parent.debug('cert', "Checking certs");
151
152
// Setup renew options
159
- var renewOptions = { servername: obj.servername };
160
- if (obj.altnames.length > 0) { renewOptions.altnames = obj.altnames; }
153
+ var renewOptions = { servername: obj.leDomains[0] };
154
+ if (obj.leDomains.length > 0) { renewOptions.altnames = obj.leDomains; }
155
obj.le.renew(renewOptions)
156
.then(function (results) {
157
parent.debug('cert', "Checks completed");
158
if (obj.performRestart === true) { parent.debug('cert', "Certs changed, restarting..."); obj.parent.performServerCertUpdate(); } // Reset the server, TODO: Reset all peers
159
})
166
- .catch(function (e) { console.log(e); func(certs); });
160
+ .catch(function (e) { console.log(e); });
161
}
162
163
return obj;
@@ -176,7 +170,7 @@ module.exports.create = function (options) {
170
var manager = { parent: options.parent };
171
manager.find = async function (options) {
172
//console.log('LE-FIND', options);
179
- return Promise.resolve([ { subject: options.servername, altnames: options.altnames } ]);
173
+ return Promise.resolve([{ subject: options.servername, altnames: options.altnames }]);
174
};
175
176
manager.set = function (options) {
@@ -196,8 +190,8 @@ module.exports.create = function (options) {
190
//console.log('LE-DEFAULTS', options);
191
if (options != null) { for (var i in options) { if (manager.parent.leDefaults[i] == null) { manager.parent.leDefaults[i] = options[i]; } } }
192
var r = manager.parent.leDefaults;
199
- var mainsite = { subject: manager.parent.servername };
200
- if (manager.parent.altnames.length > 0) { mainsite.altnames = manager.parent.altnames; }
193
+ var mainsite = { subject: manager.parent.leDomains[0] };
194
+ if (manager.parent.leDomains.length > 0) { mainsite.altnames = manager.parent.leDomains; }
195
r.subscriberEmail = manager.parent.parent.config.letsencrypt.email;
196
r.sites = { mainsite: mainsite };
197
return r;
meshcentral.js
+3
-1
@@ -830,7 +830,9 @@ function CreateMeshCentralServer(config, args) {
830
// Load server certificates
831
obj.certificateOperations = require('./certoperations.js').CertificateOperations(obj);
832
obj.certificateOperations.GetMeshServerCertificate(obj.args, obj.config, function (certs) {
833
- if ((obj.config.letsencrypt == null) || (obj.redirserver == null)) {
833
+ // Get the current node version
834
+ const nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
835
+ if ((nodeVersion < 8) || (obj.config.letsencrypt == null) || (obj.redirserver == null)) {
836
obj.StartEx3(certs); // Just use the configured certificates
837
} else {
838
var le = require('./letsencrypt.js');
package.json
+2
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.4.4-c",
3
+ "version": "0.4.4-e",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
@@ -37,6 +37,7 @@
37
"express": "^4.17.0",
38
"express-handlebars": "^3.1.0",
39
"express-ws": "^4.0.0",
40
+ "greenlock": "^3.1.5",
41
"ipcheck": "^0.1.0",
42
"meshcentral": "*",
43
"minimist": "^1.2.0",
views/default-min.handlebars
+3
-2
@@ -8197,6 +8197,7 @@
8197
x += '<div><label><input type=checkbox id=p41c4 ' + ((serverTraceSources.indexOf('peer') >= 0) ? 'checked' : '') + '>' + "MeshCentral Server Peering" + '</label></div>';
8198
x += '<div><label><input type=checkbox id=p41c15 ' + ((serverTraceSources.indexOf('agent') >= 0) ? 'checked' : '') + '>' + "MeshAgent traffic" + '</label></div>';
8199
x += '<div><label><input type=checkbox id=p41c14 ' + ((serverTraceSources.indexOf('agentupdate') >= 0) ? 'checked' : '') + '>' + "MeshAgent update" + '</label></div>';
8200
+ x += '<div><label><input type=checkbox id=p41c16 ' + ((serverTraceSources.indexOf('cert') >= 0) ? 'checked' : '') + '>' + "Server Certificate" + '</label></div>';
8201
x += '<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:5px"><b>' + "Web Server" + '</b></div>';
8202
x += '<div><label><input type=checkbox id=p41c5 ' + ((serverTraceSources.indexOf('web') >= 0) ? 'checked' : '') + '>' + "Web Server" + '</label></div>';
8203
x += '<div><label><input type=checkbox id=p41c6 ' + ((serverTraceSources.indexOf('webrequest') >= 0) ? 'checked' : '') + '>' + "Web Server Requests" + '</label></div>';
@@ -8213,8 +8214,8 @@
8214
}
8215
8216
function setServerTracingEx(b) {
8216
- var sources = [], allsources = ['cookie', 'dispatch', 'main', 'peer', 'web', 'webrequest', 'relay', 'webrelaydata', 'webrelay', 'mps', 'mpscmd', 'swarm', 'swarmcmd', 'agentupdate', 'agent'];
8217
- if (b == 1) { for (var i = 1; i < 16; i++) { try { if (Q('p41c' + i).checked) { sources.push(allsources[i - 1]); } } catch (ex) { } } }
8217
+ var sources = [], allsources = ['cookie', 'dispatch', 'main', 'peer', 'web', 'webrequest', 'relay', 'webrelaydata', 'webrelay', 'mps', 'mpscmd', 'swarm', 'swarmcmd', 'agentupdate', 'agent', 'cert'];
8218
+ if (b == 1) { for (var i = 1; i < 17; i++) { try { if (Q('p41c' + i).checked) { sources.push(allsources[i - 1]); } } catch (ex) { } } }
8219
meshserver.send({ action: 'traceinfo', traceSources: sources });
8220
}
8221
views/default.handlebars
+3
-2
@@ -9179,6 +9179,7 @@
9179
x += '<div><label><input type=checkbox id=p41c4 ' + ((serverTraceSources.indexOf('peer') >= 0) ? 'checked' : '') + '>' + "MeshCentral Server Peering" + '</label></div>';
9180
x += '<div><label><input type=checkbox id=p41c15 ' + ((serverTraceSources.indexOf('agent') >= 0) ? 'checked' : '') + '>' + "MeshAgent traffic" + '</label></div>';
9181
x += '<div><label><input type=checkbox id=p41c14 ' + ((serverTraceSources.indexOf('agentupdate') >= 0) ? 'checked' : '') + '>' + "MeshAgent update" + '</label></div>';
9182
+ x += '<div><label><input type=checkbox id=p41c16 ' + ((serverTraceSources.indexOf('cert') >= 0) ? 'checked' : '') + '>' + "Server Certificate" + '</label></div>';
9183
x += '<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:5px"><b>' + "Web Server" + '</b></div>';
9184
x += '<div><label><input type=checkbox id=p41c5 ' + ((serverTraceSources.indexOf('web') >= 0) ? 'checked' : '') + '>' + "Web Server" + '</label></div>';
9185
x += '<div><label><input type=checkbox id=p41c6 ' + ((serverTraceSources.indexOf('webrequest') >= 0) ? 'checked' : '') + '>' + "Web Server Requests" + '</label></div>';
@@ -9195,8 +9196,8 @@
9196
}
9197
9198
function setServerTracingEx(b) {
9198
- var sources = [], allsources = ['cookie', 'dispatch', 'main', 'peer', 'web', 'webrequest', 'relay', 'webrelaydata', 'webrelay', 'mps', 'mpscmd', 'swarm', 'swarmcmd', 'agentupdate', 'agent'];
9199
- if (b == 1) { for (var i = 1; i < 16; i++) { try { if (Q('p41c' + i).checked) { sources.push(allsources[i - 1]); } } catch (ex) { } } }
9199
+ var sources = [], allsources = ['cookie', 'dispatch', 'main', 'peer', 'web', 'webrequest', 'relay', 'webrelaydata', 'webrelay', 'mps', 'mpscmd', 'swarm', 'swarmcmd', 'agentupdate', 'agent', 'cert'];
9200
+ if (b == 1) { for (var i = 1; i < 17; i++) { try { if (Q('p41c' + i).checked) { sources.push(allsources[i - 1]); } } catch (ex) { } } }
9201
meshserver.send({ action: 'traceinfo', traceSources: sources });
9202
}
9203
views/translations/default-min_fr.handlebars
+3
-2
@@ -8197,6 +8197,7 @@
8197
x += '<div><label><input type=checkbox id=p41c4 ' + ((serverTraceSources.indexOf('peer') >= 0) ? 'checked' : '') + '>' + "MeshCentral Server Peering" + '</label></div>';
8198
x += '<div><label><input type=checkbox id=p41c15 ' + ((serverTraceSources.indexOf('agent') >= 0) ? 'checked' : '') + '>' + "MeshAgent traffic" + '</label></div>';
8199
x += '<div><label><input type=checkbox id=p41c14 ' + ((serverTraceSources.indexOf('agentupdate') >= 0) ? 'checked' : '') + '>' + "MeshAgent update" + '</label></div>';
8200
+ x += '<div><label><input type=checkbox id=p41c16 ' + ((serverTraceSources.indexOf('cert') >= 0) ? 'checked' : '') + '>' + "Server Certificate" + '</label></div>';
8201
x += '<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:5px"><b>' + "Serveur Web" + '</b></div>';
8202
x += '<div><label><input type=checkbox id=p41c5 ' + ((serverTraceSources.indexOf('web') >= 0) ? 'checked' : '') + '>' + "Serveur Web" + '</label></div>';
8203
x += '<div><label><input type=checkbox id=p41c6 ' + ((serverTraceSources.indexOf('webrequest') >= 0) ? 'checked' : '') + '>' + "Demandes de serveur Web" + '</label></div>';
@@ -8213,8 +8214,8 @@
8214
}
8215
8216
function setServerTracingEx(b) {
8216
- var sources = [], allsources = ['cookie', 'dispatch', 'main', 'peer', 'web', 'webrequest', 'relay', 'webrelaydata', 'webrelay', 'mps', 'mpscmd', 'swarm', 'swarmcmd', 'agentupdate', 'agent'];
8217
- if (b == 1) { for (var i = 1; i < 16; i++) { try { if (Q('p41c' + i).checked) { sources.push(allsources[i - 1]); } } catch (ex) { } } }
8217
+ var sources = [], allsources = ['cookie', 'dispatch', 'main', 'peer', 'web', 'webrequest', 'relay', 'webrelaydata', 'webrelay', 'mps', 'mpscmd', 'swarm', 'swarmcmd', 'agentupdate', 'agent', 'cert'];
8218
+ if (b == 1) { for (var i = 1; i < 17; i++) { try { if (Q('p41c' + i).checked) { sources.push(allsources[i - 1]); } } catch (ex) { } } }
8219
meshserver.send({ action: 'traceinfo', traceSources: sources });
8220
}
8221
views/translations/default_fr.handlebars
+3
-2
@@ -9177,6 +9177,7 @@
9177
x += '<div><label><input type=checkbox id=p41c4 ' + ((serverTraceSources.indexOf('peer') >= 0) ? 'checked' : '') + '>' + "MeshCentral Server Peering" + '</label></div>';
9178
x += '<div><label><input type=checkbox id=p41c15 ' + ((serverTraceSources.indexOf('agent') >= 0) ? 'checked' : '') + '>' + "MeshAgent traffic" + '</label></div>';
9179
x += '<div><label><input type=checkbox id=p41c14 ' + ((serverTraceSources.indexOf('agentupdate') >= 0) ? 'checked' : '') + '>' + "MeshAgent update" + '</label></div>';
9180
+ x += '<div><label><input type=checkbox id=p41c16 ' + ((serverTraceSources.indexOf('cert') >= 0) ? 'checked' : '') + '>' + "Server Certificate" + '</label></div>';
9181
x += '<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:5px"><b>' + "Serveur Web" + '</b></div>';
9182
x += '<div><label><input type=checkbox id=p41c5 ' + ((serverTraceSources.indexOf('web') >= 0) ? 'checked' : '') + '>' + "Serveur Web" + '</label></div>';
9183
x += '<div><label><input type=checkbox id=p41c6 ' + ((serverTraceSources.indexOf('webrequest') >= 0) ? 'checked' : '') + '>' + "Demandes de serveur Web" + '</label></div>';
@@ -9193,8 +9194,8 @@
9194
}
9195
9196
function setServerTracingEx(b) {
9196
- var sources = [], allsources = ['cookie', 'dispatch', 'main', 'peer', 'web', 'webrequest', 'relay', 'webrelaydata', 'webrelay', 'mps', 'mpscmd', 'swarm', 'swarmcmd', 'agentupdate', 'agent'];
9197
- if (b == 1) { for (var i = 1; i < 16; i++) { try { if (Q('p41c' + i).checked) { sources.push(allsources[i - 1]); } } catch (ex) { } } }
9197
+ var sources = [], allsources = ['cookie', 'dispatch', 'main', 'peer', 'web', 'webrequest', 'relay', 'webrelaydata', 'webrelay', 'mps', 'mpscmd', 'swarm', 'swarmcmd', 'agentupdate', 'agent', 'cert'];
9198
+ if (b == 1) { for (var i = 1; i < 17; i++) { try { if (Q('p41c' + i).checked) { sources.push(allsources[i - 1]); } } catch (ex) { } } }
9199
meshserver.send({ action: 'traceinfo', traceSources: sources });
9200
}
9201