MPS certificate name fix, added MeshType to .msh.

Ylian Saint-Hilaire committed Oct 11, 2017 at 12:20 UTC 3632741d9e59011398d11e76792b49a5a3be75db
4 files changed +12 -9
certoperations.js
+8 -5
@@ -219,6 +219,9 @@ module.exports.CertificateOperations = function () {
219 // Fetch the Intel AMT console name
220 var consoleCertificate = obj.pki.certificateFromPem(r.console.cert);
221 r.AmtConsoleName = consoleCertificate.subject.getField('CN').value;
222 + // Fetch the Intel AMT MPS common name
223 + var mpsCertificate = obj.pki.certificateFromPem(r.mps.cert);
224 + r.AmtMpsName = mpsCertificate.subject.getField('CN').value;
225 // Fetch the name of the server
226 var webCertificate = obj.pki.certificateFromPem(r.web.cert);
227 r.CommonName = webCertificate.subject.getField('CN').value;
@@ -229,7 +232,7 @@ module.exports.CertificateOperations = function () {
232 if (xcountryField != null) { xcountry = xcountryField.value; }
233 var xorganization, xorganizationField = webCertificate.subject.getField('O');
234 if (xorganizationField != null) { xorganization = xorganizationField.value; }
232 - if ((r.CommonName == commonName) && (xcountry == country) && (xorganization == organization)) { if (func != undefined) { func(r); } return r; } else { forceWebCertGen = 1; } // If the certificate matches what we want, keep it.
235 + if ((r.CommonName == commonName) && (xcountry == country) && (xorganization == organization) && (r.AmtMpsName == commonName)) { if (func != undefined) { func(r); } return r; } else { forceWebCertGen = 1; } // If the certificate matches what we want, keep it.
236 }
237 console.log('Generating certificates...');
238
@@ -251,7 +254,7 @@ module.exports.CertificateOperations = function () {
254
255 // If the web certificate does not exist, create one
256 var webCertAndKey, webCertificate, webPrivateKey;
254 - if ((r.web == undefined) || (forceWebCertGen == 1)) {
257 + if ((r.web == null) || (forceWebCertGen == 1)) {
258 webCertAndKey = obj.IssueWebServerCertificate(rootCertAndKey, false, commonName, country, organization);
259 webCertificate = obj.pki.certificateToPem(webCertAndKey.cert);
260 webPrivateKey = obj.pki.privateKeyToPem(webCertAndKey.key);
@@ -266,7 +269,7 @@ module.exports.CertificateOperations = function () {
269
270 // If the Intel AMT MPS certificate does not exist, create one
271 var mpsCertAndKey, mpsCertificate, mpsPrivateKey;
269 - if (r.console == undefined) {
272 + if ((r.mps == null) || (forceWebCertGen == 1)) {
273 mpsCertAndKey = obj.IssueWebServerCertificate(rootCertAndKey, false, commonName, country, organization);
274 mpsCertificate = obj.pki.certificateToPem(mpsCertAndKey.cert);
275 mpsPrivateKey = obj.pki.privateKeyToPem(mpsCertAndKey.key);
@@ -281,7 +284,7 @@ module.exports.CertificateOperations = function () {
284
285 // If the Intel AMT console certificate does not exist, create one
286 var consoleCertAndKey, consoleCertificate, consolePrivateKey, amtConsoleName = 'MeshCentral';
284 - if (r.console == undefined) {
287 + if (r.console == null) {
288 consoleCertAndKey = obj.IssueWebServerCertificate(rootCertAndKey, false, amtConsoleName, country, organization, { name: 'extKeyUsage', clientAuth: true, '2.16.840.1.113741.1.2.1': true, '2.16.840.1.113741.1.2.2': true, '2.16.840.1.113741.1.2.3': true }); // Intel AMT Remote, Agent and Activation usages
289 consoleCertificate = obj.pki.certificateToPem(consoleCertAndKey.cert);
290 consolePrivateKey = obj.pki.privateKeyToPem(consoleCertAndKey.key);
@@ -297,7 +300,7 @@ module.exports.CertificateOperations = function () {
300
301 // If the mesh agent server certificate does not exist, create one
302 var agentCertAndKey, agentCertificate, agentPrivateKey;
300 - if (r.agent == undefined) {
303 + if (r.agent == null) {
304 agentCertAndKey = obj.IssueWebServerCertificate(rootCertAndKey, true, 'MeshCentralAgentServer');
305 agentCertificate = obj.pki.certificateToPem(agentCertAndKey.cert);
306 agentPrivateKey = obj.pki.privateKeyToPem(agentCertAndKey.key);
meshcentral.js
+2 -2
@@ -127,7 +127,7 @@ function CreateMeshCentralServer() {
127 // Launch MeshCentral as a child server and monitor it.
128 obj.launchChildServer = function (startLine) {
129 var child_process = require('child_process');
130 - var xprocess = child_process.exec(startLine + ' --launch', { maxBuffer: 512000 }, function (error, stdout, stderr) {
130 + var xprocess = child_process.exec(startLine + ' --launch', { maxBuffer: Infinity }, function (error, stdout, stderr) {
131 if (xprocess.xrestart == 1) {
132 setTimeout(function () { obj.launchChildServer(startLine); }, 500); // This is an expected restart.
133 } else if (xprocess.xrestart == 2) {
@@ -136,7 +136,7 @@ function CreateMeshCentralServer() {
136 } else if (xprocess.xrestart == 3) {
137 // Server self-update exit
138 var child_process = require('child_process');
139 - var xxprocess = child_process.exec('npm install meshcentral', { maxBuffer: 512000, cwd: obj.path.join(__dirname, '../..') }, function (error, stdout, stderr) { });
139 + var xxprocess = child_process.exec('npm install meshcentral', { maxBuffer: Infinity, cwd: obj.path.join(__dirname, '../..') }, function (error, stdout, stderr) { });
140 xxprocess.data = '';
141 xxprocess.stdout.on('data', function (data) { xxprocess.data += data; });
142 xxprocess.stderr.on('data', function (data) { xxprocess.data += data; });
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.0.8-s",
3 + "version": "0.0.8-u",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",
webserver.js
+1 -1
@@ -1951,7 +1951,7 @@ module.exports.CreateWebServer = function (parent, db, args, secret, certificate
1951
1952 var xdomain = domain.id;
1953 if (xdomain != '') xdomain += "/";
1954 - var meshsettings = "MeshName=" + mesh.name + "\r\nMeshID=0x" + req.query.id.toUpperCase() + "\r\nServerID=" + obj.agentCertificatHashHex.toUpperCase() + "\r\n";
1954 + var meshsettings = "MeshName=" + mesh.name + "\r\nMeshType=" + mesh.mtype + "\r\nMeshID=0x" + req.query.id.toUpperCase() + "\r\nServerID=" + obj.agentCertificatHashHex.toUpperCase() + "\r\n";
1955 if (obj.args.lanonly != true) { meshsettings += "MeshServer=ws" + (obj.args.notls ? '' : 's') + "://" + certificates.CommonName + ":" + obj.args.port + "/" + xdomain + "agent.ashx\r\n"; } else { meshsettings += "MeshServer=local"; }
1956
1957 res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename=meshagent.msh' });