Added support to set 802.1x on WIFI profiles.
Ylian Saint-Hilaire committed
Mar 21, 2022 at 17:34 UTC
0f329a6f4e6c35b6a16e41407bb5fa90d79b79a3
2 files changed
+50
-6
amtmanager.js
+50
-5
@@ -1297,7 +1297,7 @@ module.exports.CreateAmtManager = function (parent) {
1297
// Get the current list of WIFI profiles and wireless interface state
1298
dev.taskCount = 1;
1299
dev.taskCompleted = func;
1300
- dev.amtstack.BatchEnum(null, ['CIM_WiFiEndpointSettings', '*CIM_WiFiPort', '*AMT_WiFiPortConfigurationService'], function (stack, name, responses, status) {
1300
+ dev.amtstack.BatchEnum(null, ['CIM_WiFiEndpointSettings', '*CIM_WiFiPort', '*AMT_WiFiPortConfigurationService', 'CIM_IEEE8021xSettings'], function (stack, name, responses, status) {
1301
const dev = stack.dev;
1302
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1303
if (status != 200) { devTaskCompleted(dev); return; } // We can't get wireless settings, ignore and carry on.
@@ -1307,6 +1307,7 @@ module.exports.CreateAmtManager = function (parent) {
1307
// The server and device WIFI profiles, find profiles to add and remove
1308
const sevProfiles = parent.config.domains[dev.domainid].amtmanager.wifiprofiles;
1309
const devProfiles = responses['CIM_WiFiEndpointSettings'].responses;
1310
+ const netAuthProfiles = responses['CIM_IEEE8021xSettings'].responses;
1311
var profilesToAdd = [], profilesToRemove = [];
1312
1313
// Look at the WIFI profiles in the device
@@ -1320,13 +1321,38 @@ module.exports.CreateAmtManager = function (parent) {
1321
(devProfile.AuthenticationMethod == sevProfile.authentication) &&
1322
(devProfile.EncryptionMethod == sevProfile.encryption) &&
1323
(devProfile.BSSType == sevProfile.type)
1323
- ) { match = true; devProfile.match = true; }
1324
+ ) {
1325
+ if (([5, 7, 32768, 32769].indexOf(sevProfile.authentication)) >= 0) {
1326
+ // This is a 802.1x profile, do some extra matching.
1327
+ // Start by finding the 802.1x profile for this WIFI profile
1328
+ var netAuthProfile = null, netAuthMatch = false;
1329
+ for (var k in netAuthProfiles) { if (netAuthProfiles[k].ElementName == devProfile.ElementName) { netAuthProfile = netAuthProfiles[k]; } }
1330
+ if (netAuthProfile != null) {
1331
+ netAuthMatch = true;
1332
+ if (sevProfile['802.1x'].authenticationprotocol != netAuthProfile['AuthenticationProtocol']) { console.log('Y1'); netAuthMatch = false; }
1333
+ if (sevProfile['802.1x'].roamingidentity != netAuthProfile['RoamingIdentity']) { console.log('Y3'); netAuthMatch = false; }
1334
+ if (sevProfile['802.1x'].servercertificatename != netAuthProfile['ServerCertificateName']) { console.log('Y4'); netAuthMatch = false; }
1335
+ if (sevProfile['802.1x'].servercertificatenamecomparison != netAuthProfile['ServerCertificateNameComparison']) { console.log('Y5'); netAuthMatch = false; }
1336
+ if (sevProfile['802.1x'].username != netAuthProfile['Username']) { console.log('Y6'); netAuthMatch = false; }
1337
+ if (sevProfile['802.1x'].domain != netAuthProfile['Domain']) { console.log('Y7'); netAuthMatch = false; }
1338
+ }
1339
+ if (netAuthMatch == true) {
1340
+ // The 802.1x profile seems to match what we want
1341
+ match = true;
1342
+ devProfile.match = true;
1343
+ }
1344
+ } else {
1345
+ // Not a 802.1x profile, match now.
1346
+ match = true;
1347
+ devProfile.match = true;
1348
+ }
1349
+ }
1350
}
1351
if (match == false) { profilesToAdd.push(sevProfile); }
1352
}
1353
for (var j in devProfiles) {
1354
var devProfile = devProfiles[j];
1329
- if (devProfile.match !== true) { profilesToRemove.push(devProfile); }
1355
+ if ((devProfile.match !== true) && (devProfile.InstanceID != null)) { profilesToRemove.push(devProfile); }
1356
}
1357
1358
// Compute what priorities are allowed
@@ -1360,10 +1386,29 @@ module.exports.CreateAmtManager = function (parent) {
1386
EncryptionMethod: profileToAdd.encryption,
1387
SSID: profileToAdd.ssid,
1388
Priority: nextPriority,
1363
- PSKPassPhrase: profileToAdd.password
1389
+ }
1390
+ var netAuthProfile, netAuthSettingsClientCert, netAuthSettingsServerCaCert;
1391
+ if (([4, 6].indexOf(profileToAdd.authentication)) >= 0) { wifiepsettinginput['PSKPassPhrase'] = profileToAdd.password; }
1392
+ if (([5, 7, 32768, 32769].indexOf(profileToAdd.authentication)) >= 0) {
1393
+ netAuthProfile = {
1394
+ '__parameterType': 'instance',
1395
+ '__namespace': dev.amtstack.CompleteName('CIM_IEEE8021xSettings'),
1396
+ 'ElementName': '8021x-' + profileToAdd.name,
1397
+ 'InstanceID': '8021x-' + profileToAdd.name,
1398
+ 'ActiveInS0': (profileToAdd['802.1x'].availableins0 !== false),
1399
+ 'AuthenticationProtocol': profileToAdd['802.1x'].authenticationprotocol
1400
+ };
1401
+ if (profileToAdd['802.1x'].roamingidentity) { netAuthProfile['RoamingIdentity'] = profileToAdd['802.1x'].roamingidentity; }
1402
+ if (profileToAdd['802.1x'].servercertificatename) { netAuthProfile['ServerCertificateName'] = profileToAdd['802.1x'].servercertificatename; netAuthProfile['ServerCertificateNameComparison'] = profileToAdd['802.1x'].servercertificatenamecomparison; }
1403
+ if (profileToAdd['802.1x'].username) { netAuthProfile['Username'] = profileToAdd['802.1x'].username; }
1404
+ if (profileToAdd['802.1x'].password) { netAuthProfile['Password'] = profileToAdd['802.1x'].password; }
1405
+ if (profileToAdd['802.1x'].domain) { netAuthProfile['Domain'] = profileToAdd['802.1x'].domain; }
1406
+ if (profileToAdd['802.1x'].authenticationprotocol > 3) { netAuthProfile['ProtectedAccessCredential'] = profileToAdd['802.1x'].protectedaccesscredentialhex; netAuthProfile['PACPassword'] = profileToAdd['802.1x'].pacpassword; }
1407
+ //if (parseInt(Q('idx_d12clientcert').value) >= 0) { 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">' + xxCertificates[parseInt(Q('idx_d12clientcert').value)]['InstanceID'] + '</Selector></SelectorSet></ReferenceParameters>'; }
1408
+ //if (parseInt(Q('idx_d12servercert').value) >= 0) { 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">' + xxCertificates[parseInt(Q('idx_d12servercert').value)]['InstanceID'] + '</Selector></SelectorSet></ReferenceParameters>'; }
1409
}
1410
prioritiesInUse.push(nextPriority); // Occupy the priority slot and add the WIFI profile.
1366
- dev.amtstack.AMT_WiFiPortConfigurationService_AddWiFiSettings(wifiep, wifiepsettinginput, null, null, null, function (stack, name, responses, status) { });
1411
+ dev.amtstack.AMT_WiFiPortConfigurationService_AddWiFiSettings(wifiep, wifiepsettinginput, netAuthProfile, netAuthSettingsClientCert, netAuthSettingsServerCaCert, function (stack, name, responses, status) { });
1412
}
1413
}
1414
file1.txt
deleted
-1
@@ -1 +0,0 @@
1
-0.9.99