Intel AMT TLS ACM activation improvements.

Ylian Saint-Hilaire committed Jul 31, 2021 at 01:53 UTC 7d867dae6926c2fea1626c118a81ac7a55b50c17
2 files changed +7 -6
amtmanager.js
+5 -3
@@ -2014,7 +2014,7 @@ module.exports.CreateAmtManager = function (parent) {
2014 const activationCerts = domain.amtacmactivation.certs;
2015 if ((dev.mpsConnection.tag.meiState == null) || (dev.mpsConnection.tag.meiState.Hashes == null) || (dev.mpsConnection.tag.meiState.Hashes.length == 0)) return { err: "Intel AMT did not report any trusted hashes." };
2016 const deviceHashes = dev.mpsConnection.tag.meiState.Hashes;
2017 -
2017 +
2018 // Get the trusted FQDN of the device
2019 var trustedFqdn = null;
2020 if (dev.mpsConnection.tag.meiState.OsDnsSuffix != null) { trustedFqdn = dev.mpsConnection.tag.meiState.OsDnsSuffix; }
@@ -2023,6 +2023,7 @@ module.exports.CreateAmtManager = function (parent) {
2023
2024 // Find a matching certificate
2025 var gotSuffixMatch = false;
2026 + var devValidHash = false;
2027 for (var i in activationCerts) {
2028 var cert = activationCerts[i];
2029 var certDnsMatch = checkAcmActivationCertName(cert.cn, trustedFqdn);
@@ -2031,12 +2032,14 @@ module.exports.CreateAmtManager = function (parent) {
2032 for (var j in deviceHashes) {
2033 var hashInfo = deviceHashes[j];
2034 if ((hashInfo != null) && (hashInfo.isActive == 1)) {
2035 + devValidHash = true;
2036 if ((hashInfo.hashAlgorithmStr == 'SHA256') && (hashInfo.certificateHash.toLowerCase() == cert.sha256)) { return { cert: cert, fqdn: trustedFqdn, hash: cert.sha256 }; } // Found a match
2037 else if ((hashInfo.hashAlgorithmStr == 'SHA1') && (hashInfo.certificateHash.toLowerCase() == cert.sha1)) { return { cert: cert, fqdn: trustedFqdn, hash: cert.sha1 }; } // Found a match
2038 }
2039 }
2040 }
2041 }
2042 + if (!devValidHash) { return { err: "Intel AMT has no trusted root hashes for \"" + trustedFqdn + "\"." }; } // Found no trusted root hashes
2043 if (gotSuffixMatch) { return { err: "Certificate root hash matching failed for \"" + trustedFqdn + "\"." }; } // Found a DNS suffix match, but root hash failed to match.
2044 return { err: "No matching ACM activation certificate for \"" + trustedFqdn + "\"." }; // Did not find a match
2045 }
@@ -2060,7 +2063,6 @@ module.exports.CreateAmtManager = function (parent) {
2063 // Get our ACM activation certificate chain
2064 var acmTlsInfo = parent.certificateOperations.getAcmCertChain(parent.config.domains[dev.domainid], dev.temp.acminfo.fqdn, dev.temp.acminfo.hash);
2065 if (acmTlsInfo.error == 1) { dev.consoleMsg(acmTlsInfo.errorText); removeAmtDevice(dev, 44); return; }
2063 - acmTlsInfo.certs = acmTlsInfo.certs.reverse(); // Reverse the order of the certificates.
2066 dev.acmTlsInfo = acmTlsInfo;
2067
2068 // Send the MEI command to enable TLS connections
@@ -2097,7 +2099,7 @@ module.exports.CreateAmtManager = function (parent) {
2099
2100 // Check if we succesfully connected
2101 if (status != 200) {
2100 - dev.consoleMsg("Failed to perform ACM TLS connection.");
2102 + dev.consoleMsg("Failed to perform ACM TLS connection, status " + status + ".");
2103 //activateIntelAmtAcm(dev); // It's possible to fallback to legacy WSMAN ACM activation here if we needed to..
2104 removeAmtDevice(dev);
2105 return;
certoperations.js
+2 -3
@@ -59,8 +59,7 @@ module.exports.CertificateOperations = function (parent) {
59 var leafcert = obj.IssueWebServerCertificate(rootcert, false, fqdn, 'mc', 'Intel(R) Client Setup Certificate', { serverAuth: true, '2.16.840.1.113741.1.2.3': true }, false);
60
61 // Setup the certificate chain and key
62 - //certChain = [ obj.pki.certificateToPem(leafcert.cert), obj.pki.certificateToPem(domain.amtacmactivation.certs[certIndex].rootcert) ];
63 - certChain = [ obj.pki.certificateToPem(domain.amtacmactivation.certs[certIndex].rootcert), obj.pki.certificateToPem(leafcert.cert) ];
62 + certChain = [ obj.pki.certificateToPem(leafcert.cert), obj.pki.certificateToPem(domain.amtacmactivation.certs[certIndex].rootcert) ];
63 signkey = obj.pki.privateKeyToPem(leafcert.key);
64 } else {
65 // Make sure the cert chain is in PEM format
@@ -70,7 +69,7 @@ module.exports.CertificateOperations = function (parent) {
69 }
70
71 // Hash the leaf certificate and return the certificate chain and signing key
73 - return { action: 'acmactivate', certs: certChain, signkey: signkey, hash384: obj.getCertHash(certChain[certChain.length - 1]), hash256: obj.getCertHashSha256(certChain[certChain.length - 1]) };
72 + return { action: 'acmactivate', certs: certChain, signkey: signkey, hash384: obj.getCertHash(certChain[0]), hash256: obj.getCertHashSha256(certChain[0]) };
73 }
74
75 // Sign a Intel AMT ACM activation request