From 537409e964f3400b0f4af3dd398853fbd088bc1a Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Sat, 18 Jun 2022 10:54:13 -0700 Subject: [PATCH] Fixed server exception when settings .msh random without custom agent signing cert. --- meshcentral.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/meshcentral.js b/meshcentral.js index 48def834..8b27643e 100644 --- a/meshcentral.js +++ b/meshcentral.js @@ -2851,7 +2851,6 @@ function CreateMeshCentralServer(config, args) { // Check if a custom agent signing certificate is available var agentSignCertInfo = require('./authenticode.js').loadCertificates([obj.path.join(obj.datapath, 'agentsigningcert.pem')]); - if (agentSignCertInfo == null) { func(); return; } // No code signing certificate, nothing to do. // If not using a custom signing cert, get agent code signature certificate ready with the full cert chain if ((agentSignCertInfo == null) && (obj.certificates.codesign != null)) { @@ -2861,6 +2860,7 @@ function CreateMeshCentralServer(config, args) { extraCerts: [obj.certificateOperations.forge.pki.certificateFromPem(obj.certificates.root.cert)] } } + if (agentSignCertInfo == null) { func(); return; } // No code signing certificate, nothing to do. // Setup the domain is specified var objx = domain, suffix = ''; @@ -2955,6 +2955,15 @@ function CreateMeshCentralServer(config, args) { // Check if a custom agent signing certificate is available var agentSignCertInfo = require('./authenticode.js').loadCertificates([obj.path.join(obj.datapath, 'agentsigningcert.pem')]); + // If not using a custom signing cert, get agent code signature certificate ready with the full cert chain + if ((agentSignCertInfo == null) && (obj.certificates.codesign != null)) { + agentSignCertInfo = { + cert: obj.certificateOperations.forge.pki.certificateFromPem(obj.certificates.codesign.cert), + key: obj.certificateOperations.forge.pki.privateKeyFromPem(obj.certificates.codesign.key), + extraCerts: [obj.certificateOperations.forge.pki.certificateFromPem(obj.certificates.root.cert)] + } + } + // Setup the domain is specified var objx = domain, suffix = ''; if (domain.id == '') { objx = obj; } else { suffix = '-' + domain.id; objx.meshAgentBinaries = {}; }