Added Let's Encrypt settings validation.
Ylian Saint-Hilaire committed
Dec 4, 2019 at 13:45 UTC
9210034ff63981100b17facdc030fafd12806a77
3 files changed
+18
-7
.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
meshcentral.js
+14
-6
@@ -405,7 +405,7 @@ function CreateMeshCentralServer(config, args) {
405
//wincmd.list(function (svc) { console.log(svc); }, true);
406
407
// Check top level configuration for any unreconized values
408
- if (config) { for (var i in config) { if ((typeof i == 'string') && (i.length > 0) && (i[0] != '_') && (['settings', 'domains', 'configfiles', 'smtp', 'letsencrypt', 'peers'].indexOf(i) == -1)) { addServerWarning('WARNING: unrecognized configuration option \"' + i + '\".'); } } }
408
+ if (config) { for (var i in config) { if ((typeof i == 'string') && (i.length > 0) && (i[0] != '_') && (['settings', 'domains', 'configfiles', 'smtp', 'letsencrypt', 'peers'].indexOf(i) == -1)) { addServerWarning('Unrecognized configuration option \"' + i + '\".'); } } }
409
410
if (typeof obj.args.userallowedip == 'string') { if (obj.args.userallowedip == '') { obj.args.userallowedip = null; } else { obj.args.userallowedip = obj.args.userallowedip.split(','); } }
411
if (typeof obj.args.userblockedip == 'string') { if (obj.args.userblockedip == '') { obj.args.userblockedip = null; } else { obj.args.userblockedip = obj.args.userblockedip.split(','); } }
@@ -895,12 +895,20 @@ function CreateMeshCentralServer(config, args) {
895
if ((nodeVersion < 8) || (require('crypto').generateKeyPair == null) || (obj.config.letsencrypt == null) || (obj.redirserver == null)) {
896
obj.StartEx3(certs); // Just use the configured certificates
897
} else {
898
- var le = require('./letsencrypt.js');
899
- obj.letsencrypt = le.CreateLetsEncrypt(obj);
900
- if (obj.letsencrypt != null) {
901
- obj.letsencrypt.getCertificate(certs, obj.StartEx3); // Use Let's Encrypt certificate
898
+ // Check Let's Encrypt settings
899
+ var leok = true;
900
+ if (typeof obj.config.letsencrypt.email != 'string') { leok = false; addServerWarning("Missing Let's Encrypt email address."); }
901
+ else if (typeof obj.config.letsencrypt.names != 'string') { leok = false; addServerWarning("Invalid Let's Encrypt host names."); }
902
+ else if (obj.config.letsencrypt.email.split('@').length != 2) { leok = false; addServerWarning("Invalid Let's Encrypt email address."); }
903
+ else if (obj.config.letsencrypt.email.trim() !== obj.config.letsencrypt.email) { leok = false; addServerWarning("Invalid Let's Encrypt email address."); }
904
+ else {
905
+ var le = require('./letsencrypt.js');
906
+ try { obj.letsencrypt = le.CreateLetsEncrypt(obj); } catch (ex) { }
907
+ if (obj.letsencrypt == null) { addServerWarning("Unable to setup GreenLock module."); leok = false; }
908
+ }
909
+ if (leok == true) {
910
+ obj.letsencrypt.getCertificate(certs, obj.StartEx3); // Use Let's Encrypt
911
} else {
903
- console.log("ERROR: Unable to setup GreenLock module.");
912
obj.StartEx3(certs); // Let's Encrypt did not load, just use the configured certificates
913
}
914
}
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.4.5-f",
3
+ "version": "0.4.5-g",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",