Intel AMT ACM activation fully working.

Ylian Saint-Hilaire committed Jun 20, 2019 at 18:23 UTC 57b4b6cde2f37124877960b01fc8bb2492a72552
6 files changed +39 -14
certoperations.js
+26 -10
@@ -83,11 +83,28 @@ module.exports.CertificateOperations = function (parent) {
83 var acmCerts = [], acmmatch = [];
84 if (amtacmactivation.certs != null) {
85 for (var j in amtacmactivation.certs) {
86 - var acmconfig = amtacmactivation.certs[j];
87 - if (typeof acmconfig.cert != 'string') continue;
88 - var r = null;
89 - try { r = obj.loadPfxCertificate(obj.parent.path.join(obj.parent.datapath, acmconfig.cert), acmconfig.certpass); } catch (ex) { console.log(ex); }
90 - if ((r == null) || (r.certs == null) || (r.keys == null) || (r.certs.length < 2) || (r.keys.length != 1)) continue;
86 + var acmconfig = amtacmactivation.certs[j], r = null;
87 +
88 + if ((typeof acmconfig.certpfx == 'string') && (typeof acmconfig.certpfxpass == 'string')) {
89 + // P12 format, certpfx and certpfxpass
90 + try { r = obj.loadPfxCertificate(obj.parent.path.join(obj.parent.datapath, acmconfig.certpfx), acmconfig.certpfxpass); } catch (ex) { console.log(ex); }
91 + if ((r == null) || (r.certs == null) || (r.keys == null) || (r.certs.length < 2) || (r.keys.length != 1)) continue;
92 + } else if ((typeof acmconfig.certfiles == 'object') && (typeof acmconfig.keyfile == 'string')) {
93 + // PEM format, certfiles and keyfile
94 + r = { certs: [], keys: [] };
95 + for (var k in acmconfig.certfiles) { r.certs.push(obj.pki.certificateFromPem(obj.fs.readFileSync(obj.parent.path.join(obj.parent.datapath, acmconfig.certfiles[k])))); }
96 + r.keys.push(obj.pki.privateKeyFromPem(obj.fs.readFileSync(obj.parent.path.join(obj.parent.datapath, acmconfig.keyfile))));
97 + if ((r.certs.length < 2) || (r.keys.length != 1)) continue;
98 + }
99 +
100 + /*
101 + // Debug: Display all certs & key as PEM
102 + for (var k in r.certs) {
103 + var cn = r.certs[k].subject.getField('CN');
104 + if (cn != null) { console.log(cn.value + '\r\n' + obj.pki.certificateToPem(r.certs[k])); } else { console.log(obj.pki.certificateToPem(r.certs[k])); }
105 + }
106 + console.log(obj.pki.privateKeyToPem(r.keys[0]));
107 + */
108
109 // Check if the right OU or OID is present for Intel AMT activation
110 var validActivationCert = false;
@@ -164,14 +181,13 @@ module.exports.CertificateOperations = function (parent) {
181 // Return the certificate of the remote HTTPS server
182 obj.loadPfxCertificate = function (filename, password) {
183 var r = { certs: [], keys: [] };
167 - var pfxbuf = obj.fs.readFileSync(filename);
168 - var pfxb64 = Buffer.from(pfxbuf).toString('base64');
169 - var pfxder = obj.forge.util.decode64(pfxb64);
170 - var asn = obj.forge.asn1.fromDer(pfxder);
171 - var pfx = obj.forge.pkcs12.pkcs12FromAsn1(asn, true, password);
184 + var pfxb64 = Buffer.from(obj.fs.readFileSync(filename)).toString('base64');
185 + var pfx = obj.forge.pkcs12.pkcs12FromAsn1(obj.forge.asn1.fromDer(obj.forge.util.decode64(pfxb64)), true, password);
186 +
187 // Get the certs from certbags
188 var bags = pfx.getBags({ bagType: obj.forge.pki.oids.certBag });
189 for (var i = 0; i < bags[obj.forge.pki.oids.certBag].length; i++) { r.certs.push(bags[obj.forge.pki.oids.certBag][i].cert); }
190 +
191 // Get shrouded key from key bags
192 bags = pfx.getBags({ bagType: obj.forge.pki.oids.pkcs8ShroudedKeyBag });
193 for (var i = 0; i < bags[obj.forge.pki.oids.pkcs8ShroudedKeyBag].length; i++) { r.keys.push(bags[obj.forge.pki.oids.pkcs8ShroudedKeyBag][i].key); }
meshagent.js
+1 -1
@@ -1232,7 +1232,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1232 ChangeAgentCoreInfo({ "intelamt": { user: 'admin', pass: amtpassword, uuid: command.uuid, realm: command.realm } });
1233
1234 // Send the activation response
1235 - //obj.send(JSON.stringify(signResponse));
1235 + obj.send(JSON.stringify(signResponse));
1236 }
1237 break;
1238 }
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.3.6-r",
3 + "version": "0.3.6-s",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",
sample-config.json
+9
@@ -82,6 +82,15 @@
82 "_MaxAgentSessions": 100,
83 "MaxSingleUserSessions": 10
84 },
85 + "_AmtAcmActivation": {
86 + "log": "amtactivation.log",
87 + "certs": {
88 + "mycertname": {
89 + "certfiles": [ "amtacm-leafcert.crt", "amtacm-intermediate1.crt", "amtacm-intermediate2.crt", "amtacm-rootcert.crt" ],
90 + "keyfile": "amtacm-leafcert.key"
91 + }
92 + }
93 + },
94 "_Redirects": {
95 "meshcommander": "https://www.meshcommander.com/"
96 },
views/default-min.handlebars
+1 -1
@@ -9885,7 +9885,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
9885 }
9886
9887 // Attribute: Mesh Agent
9888 - var agentsStr = ['Unknown', 'Windows 32bit console', 'Windows 64bit console', 'Windows 32bit service', 'Windows 64bit service', 'Linux 32bit', 'Linux 64bit', 'MIPS', 'XENx86', 'Android ARM', 'Linux ARM', 'MacOS 32bit', 'Android x86', 'PogoPlug ARM', 'Android APK', 'Linux Poky x86-32bit', 'MacOS 64bit', 'ChromeOS', 'Linux Poky x86-64bit', 'Linux NoKVM x86-32bit', 'Linux NoKVM x86-64bit', 'Windows MinCore console', 'Windows MinCore service', 'NodeJS', 'ARM-Linaro', 'ARMv6l / ARMv7l', 'ARMv8 64bit'];
9888 + var agentsStr = ['Unknown', 'Windows 32bit console', 'Windows 64bit console', 'Windows 32bit service', 'Windows 64bit service', 'Linux 32bit', 'Linux 64bit', 'MIPS', 'XENx86', 'Android ARM', 'Linux ARM', 'MacOS 32bit', 'Android x86', 'PogoPlug ARM', 'Android APK', 'Linux Poky x86-32bit', 'MacOS 64bit', 'ChromeOS', 'Linux Poky x86-64bit', 'Linux NoKVM x86-32bit', 'Linux NoKVM x86-64bit', 'Windows MinCore console', 'Windows MinCore service', 'NodeJS', 'ARM-Linaro', 'ARMv6l / ARMv7l', 'ARMv8 64bit', 'Unknown', 'Unknown', 'Unknown', 'FreeBSD x86-64'];
9889 if ((node.agent != null) && (node.agent.id != null) && (node.agent.ver != null)) {
9890 var str = '';
9891 if (node.agent.id <= agentsStr.length) { str = agentsStr[node.agent.id]; } else { str = agentsStr[0]; }
views/default.handlebars
+1 -1
@@ -3830,7 +3830,7 @@
3830 }
3831
3832 // Attribute: Mesh Agent
3833 - var agentsStr = ['Unknown', 'Windows 32bit console', 'Windows 64bit console', 'Windows 32bit service', 'Windows 64bit service', 'Linux 32bit', 'Linux 64bit', 'MIPS', 'XENx86', 'Android ARM', 'Linux ARM', 'MacOS 32bit', 'Android x86', 'PogoPlug ARM', 'Android APK', 'Linux Poky x86-32bit', 'MacOS 64bit', 'ChromeOS', 'Linux Poky x86-64bit', 'Linux NoKVM x86-32bit', 'Linux NoKVM x86-64bit', 'Windows MinCore console', 'Windows MinCore service', 'NodeJS', 'ARM-Linaro', 'ARMv6l / ARMv7l', 'ARMv8 64bit'];
3833 + var agentsStr = ['Unknown', 'Windows 32bit console', 'Windows 64bit console', 'Windows 32bit service', 'Windows 64bit service', 'Linux 32bit', 'Linux 64bit', 'MIPS', 'XENx86', 'Android ARM', 'Linux ARM', 'MacOS 32bit', 'Android x86', 'PogoPlug ARM', 'Android APK', 'Linux Poky x86-32bit', 'MacOS 64bit', 'ChromeOS', 'Linux Poky x86-64bit', 'Linux NoKVM x86-32bit', 'Linux NoKVM x86-64bit', 'Windows MinCore console', 'Windows MinCore service', 'NodeJS', 'ARM-Linaro', 'ARMv6l / ARMv7l', 'ARMv8 64bit', 'Unknown', 'Unknown', 'Unknown', 'FreeBSD x86-64'];
3834 if ((node.agent != null) && (node.agent.id != null) && (node.agent.ver != null)) {
3835 var str = '';
3836 if (node.agent.id <= agentsStr.length) { str = agentsStr[node.agent.id]; } else { str = agentsStr[0]; }