From bdd1a5b2e24c3f200d1dfdeefa95927f96ab9762 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 29 Oct 2019 14:05:58 -0700 Subject: [PATCH] Fixed what certificate name is used. --- certoperations.js | 11 +++++------ package.json | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/certoperations.js b/certoperations.js index 6cbcbbc5..b721d18e 100644 --- a/certoperations.js +++ b/certoperations.js @@ -497,13 +497,12 @@ module.exports.CertificateOperations = function (parent) { r.AmtMpsName = obj.pki.certificateFromPem(r.mps.cert).subject.getField("CN").value; var webCertificate = obj.pki.certificateFromPem(r.web.cert); r.WebIssuer = webCertificate.issuer.getField("CN").value; - r.CommonName = webCertificate.subject.getField("CN").value; - if (r.CommonName.startsWith('*.')) { - 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; } - if (commonName.startsWith('*.')) { console.log("ERROR: Server can't use a wildcard name: " + commonName); process.exit(0); return; } - r.CommonName = commonName; + 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). + commonName = webCertificate.subject.getField("CN").value; + 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; } } - r.CommonNames = [ r.CommonName.toLowerCase() ]; + r.CommonName = commonName; + r.CommonNames = [commonName.toLowerCase()]; var altNames = webCertificate.getExtension("subjectAltName"); if (altNames) { for (i = 0; i < altNames.altNames.length; i++) { diff --git a/package.json b/package.json index 1094d208..a2dd4bb8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.4.3-m", + "version": "0.4.3-o", "keywords": [ "Remote Management", "Intel AMT",