Fixed what certificate name is used.

Ylian Saint-Hilaire committed Oct 29, 2019 at 14:05 UTC 41393d12a889aee8179180f45b58905c25dfb54e
2 files changed +6 -7
certoperations.js
+5 -6
@@ -497,13 +497,12 @@ module.exports.CertificateOperations = function (parent) {
497 r.AmtMpsName = obj.pki.certificateFromPem(r.mps.cert).subject.getField("CN").value;
498 var webCertificate = obj.pki.certificateFromPem(r.web.cert);
499 r.WebIssuer = webCertificate.issuer.getField("CN").value;
500 - r.CommonName = webCertificate.subject.getField("CN").value;
501 - if (r.CommonName.startsWith('*.')) {
502 - if (commonName.indexOf('.') == -1) { console.log("ERROR: Must specify a server full domain name in Config.json->Settings->Cert when using a wildcard certificate."); process.exit(0); return; }
503 - if (commonName.startsWith('*.')) { console.log("ERROR: Server can't use a wildcard name: " + commonName); process.exit(0); return; }
504 - r.CommonName = commonName;
500 + if (commonName == "un-configured") { // If the "cert" name is not set, try to use the certificate CN instead (ok if the certificate is not wildcard).
501 + commonName = webCertificate.subject.getField("CN").value;
502 + if (commonName.startsWith('*.')) { console.log("ERROR: Must specify a server full domain name in Config.json->Settings->Cert when using a wildcard certificate."); process.exit(0); return; }
503 }
506 - r.CommonNames = [ r.CommonName.toLowerCase() ];
504 + r.CommonName = commonName;
505 + r.CommonNames = [commonName.toLowerCase()];
506 var altNames = webCertificate.getExtension("subjectAltName");
507 if (altNames) {
508 for (i = 0; i < altNames.altNames.length; i++) {
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.4.3-m",
3 + "version": "0.4.3-o",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",