Fixed Intel AMT stack, exec with cert references would not work.
Ylian Saint-Hilaire committed
Apr 7, 2022 at 11:09 UTC
ef72e5d393e0c759a39cff0ccc9208e382617240
3 files changed
+38
-51
amt/amt.js
+15
-15
@@ -269,8 +269,7 @@ function AmtStackCreateService(wsmanStack) {
269
obj.AMT_MessageLog_GetRecords = function (IterationIdentifier, MaxReadRecords, callback_func, tag) { obj.Exec("AMT_MessageLog", "GetRecords", { "IterationIdentifier": IterationIdentifier, "MaxReadRecords": MaxReadRecords }, callback_func, tag); }
270
obj.AMT_MessageLog_GetRecord = function (IterationIdentifier, PositionToNext, callback_func) { obj.Exec("AMT_MessageLog", "GetRecord", { "IterationIdentifier": IterationIdentifier, "PositionToNext": PositionToNext }, callback_func); }
271
obj.AMT_MessageLog_PositionAtRecord = function (IterationIdentifier, MoveAbsolute, RecordNumber, callback_func) { obj.Exec("AMT_MessageLog", "PositionAtRecord", { "IterationIdentifier": IterationIdentifier, "MoveAbsolute": MoveAbsolute, "RecordNumber": RecordNumber }, callback_func); }
272
- obj.AMT_MessageLog_PositionToFirstRecord = function (callback_func, tag) {
273
- obj.Exec("AMT_MessageLog", "PositionToFirstRecord", {}, callback_func, tag); }
272
+ obj.AMT_MessageLog_PositionToFirstRecord = function (callback_func, tag) { obj.Exec("AMT_MessageLog", "PositionToFirstRecord", {}, callback_func, tag); }
273
obj.AMT_MessageLog_FreezeLog = function (Freeze, callback_func) { obj.Exec("AMT_MessageLog", "FreezeLog", { "Freeze": Freeze }, callback_func); }
274
obj.AMT_PublicKeyManagementService_AddCRL = function (Url, SerialNumbers, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddCRL", { "Url": Url, "SerialNumbers": SerialNumbers }, callback_func); }
275
obj.AMT_PublicKeyManagementService_ResetCRLList = function (_method_dummy, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "ResetCRLList", { "_method_dummy": _method_dummy }, callback_func); }
@@ -304,10 +303,7 @@ function AmtStackCreateService(wsmanStack) {
303
obj.AMT_TimeSynchronizationService_SetHighAccuracyTimeSynch = function (Ta0, Tm1, Tm2, callback_func, tag) { obj.Exec("AMT_TimeSynchronizationService", "SetHighAccuracyTimeSynch", { "Ta0": Ta0, "Tm1": Tm1, "Tm2": Tm2 }, callback_func, tag); }
304
obj.AMT_UserInitiatedConnectionService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_UserInitiatedConnectionService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
305
obj.AMT_WebUIService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func, tag) { obj.Exec("AMT_WebUIService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func, tag); }
307
- obj.AMT_WiFiPortConfigurationService_AddWiFiSettings = function (WiFiEndpoint, WiFiEndpointSettingsInput, IEEE8021xSettingsInput, ClientCredential, CACredential, callback_func) {
308
- console.log(JSON.stringify({ "WiFiEndpoint": WiFiEndpoint, "WiFiEndpointSettingsInput": WiFiEndpointSettingsInput, "IEEE8021xSettingsInput": IEEE8021xSettingsInput, "ClientCredential": ClientCredential, "CACredential": CACredential }, null, 2));
309
- obj.ExecWithXml("AMT_WiFiPortConfigurationService", "AddWiFiSettings", { "WiFiEndpoint": WiFiEndpoint, "WiFiEndpointSettingsInput": WiFiEndpointSettingsInput, "IEEE8021xSettingsInput": IEEE8021xSettingsInput, "ClientCredential": ClientCredential, "CACredential": CACredential }, callback_func);
310
- }
306
+ obj.AMT_WiFiPortConfigurationService_AddWiFiSettings = function (WiFiEndpoint, WiFiEndpointSettingsInput, IEEE8021xSettingsInput, ClientCredential, CACredential, callback_func) { obj.ExecWithXml("AMT_WiFiPortConfigurationService", "AddWiFiSettings", { "WiFiEndpoint": WiFiEndpoint, "WiFiEndpointSettingsInput": WiFiEndpointSettingsInput, "IEEE8021xSettingsInput": IEEE8021xSettingsInput, "ClientCredential": ClientCredential, "CACredential": CACredential }, callback_func); }
307
obj.AMT_WiFiPortConfigurationService_UpdateWiFiSettings = function (WiFiEndpointSettings, WiFiEndpointSettingsInput, IEEE8021xSettingsInput, ClientCredential, CACredential, callback_func) { obj.ExecWithXml("AMT_WiFiPortConfigurationService", "UpdateWiFiSettings", { "WiFiEndpointSettings": WiFiEndpointSettings, "WiFiEndpointSettingsInput": WiFiEndpointSettingsInput, "IEEE8021xSettingsInput": IEEE8021xSettingsInput, "ClientCredential": ClientCredential, "CACredential": CACredential }, callback_func); }
308
obj.AMT_WiFiPortConfigurationService_DeleteAllITProfiles = function (_method_dummy, callback_func) { obj.Exec("AMT_WiFiPortConfigurationService", "DeleteAllITProfiles", { "_method_dummy": _method_dummy }, callback_func); }
309
obj.AMT_WiFiPortConfigurationService_DeleteAllUserProfiles = function (_method_dummy, callback_func) { obj.Exec("AMT_WiFiPortConfigurationService", "DeleteAllUserProfiles", { "_method_dummy": _method_dummy }, callback_func); }
@@ -995,17 +991,21 @@ function AmtStackCreateService(wsmanStack) {
991
var endTag = hasNamespace ? '</q:' : '</';
992
var namespaceDef = hasNamespace ? (' xmlns:q="' + inInstance['__namespace'] + '"') : '';
993
var result = '<r:' + instanceName + namespaceDef + '>';
998
- for (var prop in inInstance) {
999
- if (!inInstance.hasOwnProperty(prop) || prop.indexOf('__') === 0) continue;
994
+ if (typeof inInstance == 'string') {
995
+ result += inInstance;
996
+ } else {
997
+ for (var prop in inInstance) {
998
+ if (!inInstance.hasOwnProperty(prop) || prop.indexOf('__') === 0) continue;
999
1001
- if (typeof inInstance[prop] === 'function' || Array.isArray(inInstance[prop])) continue;
1000
+ if (typeof inInstance[prop] === 'function' || Array.isArray(inInstance[prop])) continue;
1001
1003
- if (typeof inInstance[prop] === 'object') {
1004
- //result += startTag + prop +'>' + instanceToXml('prop', inInstance[prop]) + endTag + prop +'>';
1005
- console.error('only convert one level down...');
1006
- }
1007
- else {
1008
- result += startTag + prop + '>' + inInstance[prop].toString() + endTag + prop + '>';
1002
+ if (typeof inInstance[prop] === 'object') {
1003
+ //result += startTag + prop +'>' + instanceToXml('prop', inInstance[prop]) + endTag + prop +'>';
1004
+ console.error('only convert one level down...');
1005
+ }
1006
+ else {
1007
+ result += startTag + prop + '>' + inInstance[prop].toString() + endTag + prop + '>';
1008
+ }
1009
}
1010
}
1011
result += '</r:' + instanceName + '>';
amtmanager.js
+5
-22
@@ -1709,6 +1709,7 @@ module.exports.CreateAmtManager = function (parent) {
1709
const wiredConfig = devNetAuthData.wiredConfig;
1710
const wirelessConfig = devNetAuthData.wirelessConfig;
1711
1712
+ var taskCounter = 0;
1713
if (wirelessConfig) {
1714
// Add missing WIFI profiles
1715
var nextPriority = 1;
@@ -1748,7 +1749,6 @@ module.exports.CreateAmtManager = function (parent) {
1749
if (domain.amtmanager['802.1x'].domain) { netAuthProfile['Domain'] = domain.amtmanager['802.1x'].domain; }
1750
if (domain.amtmanager['802.1x'].authenticationprotocol > 3) { domain.amtmanager['ProtectedAccessCredential'] = profileToAdd['802.1x'].protectedaccesscredentialhex; netAuthProfile['PACPassword'] = profileToAdd['802.1x'].pacpassword; }
1751
1751
- /*
1752
// Setup Client Certificate
1753
if (devNetAuthData.certInstanceId) {
1754
netAuthSettingsClientCert = '<a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>' + dev.amtstack.CompleteName('AMT_PublicKeyCertificate') + '</w:ResourceURI><w:SelectorSet><w:Selector Name="InstanceID">' + devNetAuthData.certInstanceId + '</w:Selector></w:SelectorSet></a:ReferenceParameters>';
@@ -1757,16 +1757,6 @@ module.exports.CreateAmtManager = function (parent) {
1757
if (devNetAuthData.rootCertInstanceId) {
1758
netAuthSettingsServerCaCert = '<a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>' + dev.amtstack.CompleteName('AMT_PublicKeyCertificate') + '</w:ResourceURI><w:SelectorSet><w:Selector Name="InstanceID">' + devNetAuthData.rootCertInstanceId + '</w:Selector></w:SelectorSet></a:ReferenceParameters>';
1759
}
1760
- */
1761
-
1762
- // Setup Client Certificate
1763
- if (devNetAuthData.certInstanceId) {
1764
- netAuthSettingsClientCert = '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">' + devNetAuthData.certInstanceId + '</Selector></SelectorSet></ReferenceParameters>';
1765
- }
1766
- // Setup Server Certificate
1767
- if (devNetAuthData.rootCertInstanceId) {
1768
- netAuthSettingsServerCaCert = '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">' + devNetAuthData.rootCertInstanceId + '</Selector></SelectorSet></ReferenceParameters>';
1769
- }
1760
1761
// If we have credentials from MeshCentral Satelite, use that
1762
if (dev.netAuthCredentials != null) {
@@ -1777,25 +1767,20 @@ module.exports.CreateAmtManager = function (parent) {
1767
}
1768
}
1769
prioritiesInUse.push(nextPriority); // Occupy the priority slot and add the WIFI profile.
1780
- console.log('AddWiFiSettings1');
1770
1771
+ taskCounter++;
1772
dev.amtstack.AMT_WiFiPortConfigurationService_AddWiFiSettings(wifiep, wifiepsettinginput, netAuthProfile, netAuthSettingsClientCert, netAuthSettingsServerCaCert, function (stack, name, response, status) {
1773
if (status != 200) { dev.consoleMsg("Unable to set WIFI profile."); }
1784
- console.log('AddWiFiSettings2', status, response);
1774
+ if (--taskCounter == 0) { attemptWifiSyncEx2(dev, devNetAuthData); } // All done, complete WIFI configuration
1775
});
1776
}
1787
-
1788
- // Complete WIFI configuration
1789
- attemptWifiSyncEx2(dev, devNetAuthData);
1790
- } else {
1791
- // Done
1792
- devTaskCompleted(dev);
1777
}
1778
+
1779
+ if (taskCounter == 0) { attemptWifiSyncEx2(dev, devNetAuthData); } // All done, complete WIFI configuration
1780
}
1781
1782
function attemptWifiSyncEx2(dev, devNetAuthData) {
1783
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1798
-
1784
const responses = devNetAuthData.responses;
1785
1786
// Check if local WIFI profile sync is enabled, if not, enabled it.
@@ -1825,8 +1810,6 @@ module.exports.CreateAmtManager = function (parent) {
1810
}
1811
}
1812
1828
- console.log('ALL GOOD');
1829
-
1813
// Done
1814
devTaskCompleted(dev);
1815
}
public/scripts/amt-0.2.0.js
+18
-14
@@ -896,20 +896,24 @@ function instanceToXml(instanceName, inInstance) {
896
var startTag = hasNamespace ? '<q:' : '<';
897
var endTag = hasNamespace ? '</q:' : '</';
898
var namespaceDef = hasNamespace ? (' xmlns:q="' + inInstance['__namespace'] + '"' ): '';
899
- var result = '<r:' + instanceName + namespaceDef + '>';
900
- for(var prop in inInstance) {
901
- if (!inInstance.hasOwnProperty(prop) || prop.indexOf('__') === 0) continue;
902
-
903
- if (typeof inInstance[prop] === 'function' || Array.isArray(inInstance[prop]) ) continue;
904
-
905
- if (typeof inInstance[prop] === 'object') {
906
- //result += startTag + prop +'>' + instanceToXml('prop', inInstance[prop]) + endTag + prop +'>';
907
- console.error('only convert one level down...');
908
- }
909
- else {
910
- result += startTag + prop +'>' + inInstance[prop].toString() + endTag + prop +'>';
911
- }
912
- }
899
+ var result = '<r:' + instanceName + namespaceDef + '>';
900
+ if (typeof inInstance == 'string') {
901
+ result += inInstance;
902
+ } else {
903
+ for (var prop in inInstance) {
904
+ if (!inInstance.hasOwnProperty(prop) || prop.indexOf('__') === 0) continue;
905
+
906
+ if (typeof inInstance[prop] === 'function' || Array.isArray(inInstance[prop])) continue;
907
+
908
+ if (typeof inInstance[prop] === 'object') {
909
+ //result += startTag + prop +'>' + instanceToXml('prop', inInstance[prop]) + endTag + prop +'>';
910
+ console.error('only convert one level down...');
911
+ }
912
+ else {
913
+ result += startTag + prop + '>' + inInstance[prop].toString() + endTag + prop + '>';
914
+ }
915
+ }
916
+ }
917
result += '</r:' + instanceName + '>';
918
return result;
919
}