mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-07 04:42:54 -05:00
externalsignjob - External Code Signing Job (#6977)
* Moving external call back into meshcentral * Debugging logging * Moved the external call to the callback function * Updated codesigning.md * Move callback invoke of callExternalSignJob outside of err check * change console.log to obj.debug for external sign job call logging * obj debug signing failed using obj.debug and console.error inside callExternalSignJob
This commit is contained in:
@@ -3415,6 +3415,7 @@ function CreateMeshCentralServer(config, args) {
|
||||
// Failed to sign agent
|
||||
addServerWarning('Failed to sign \"' + agentSignedFunc.objx.meshAgentsArchitectureNumbers[agentSignedFunc.archid].localname + '\": ' + err, 22, [agentSignedFunc.objx.meshAgentsArchitectureNumbers[agentSignedFunc.archid].localname, err]);
|
||||
}
|
||||
obj.callExternalSignJob(agentSignedFunc.signingArguments); // Call external signing job regardless of success or failure
|
||||
if (--pendingOperations === 0) { agentSignedFunc.func(); }
|
||||
}
|
||||
pendingOperations++;
|
||||
@@ -3470,7 +3471,10 @@ function CreateMeshCentralServer(config, args) {
|
||||
}
|
||||
|
||||
const signingArguments = { out: signeedagentpath, desc: signDesc, url: signUrl, time: timeStampUrl, proxy: timeStampProxy }; // Shallow clone
|
||||
signingArguments.resChanges = resChanges;
|
||||
|
||||
obj.debug('main', "Code signing with arguments: " + JSON.stringify(signingArguments));
|
||||
xagentSignedFunc.signingArguments = signingArguments; // Attach the signing arguments to the callback function
|
||||
if (resChanges == false) {
|
||||
// Sign the agent the simple way, without changing any resources.
|
||||
originalAgent.sign(agentSignCertInfo, signingArguments, xagentSignedFunc);
|
||||
@@ -3479,16 +3483,40 @@ function CreateMeshCentralServer(config, args) {
|
||||
// NOTE: This is experimental and could corupt the agent.
|
||||
originalAgent.writeExecutable(signingArguments, agentSignCertInfo, xagentSignedFunc);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Signed agent is already ok, use it.
|
||||
originalAgent.close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (--pendingOperations === 0) { func(); }
|
||||
}
|
||||
|
||||
obj.callExternalSignJob = function (signingArguments) {
|
||||
if (obj.config.settings && !obj.config.settings.externalsignjob) {
|
||||
return;
|
||||
}
|
||||
obj.debug('main', "External signing job called for file: " + signingArguments.out);
|
||||
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const signResult = spawnSync('"' + obj.config.settings.externalsignjob + '"', ['"' + signingArguments.out + '"'], {
|
||||
encoding: 'utf-8',
|
||||
shell: true,
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
if (signResult.error || signResult.status !== 0) {
|
||||
obj.debug('main', "External signing failed for file: " + signingArguments.out);
|
||||
console.error("External signing failed for file: " + signingArguments.out);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the list of available mesh agents
|
||||
obj.updateMeshAgentsTable = function (domain, func) {
|
||||
// Check if a custom agent signing certificate is available
|
||||
|
||||
Reference in New Issue
Block a user