1
0
mirror of https://github.com/Ylianst/MeshCommander synced 2025-12-06 06:03:20 +00:00

Added HTTPS boot.

This commit is contained in:
Ylian Saint-Hilaire
2020-06-24 00:41:05 -07:00
parent 35d9273cfd
commit 921f46f32b
2 changed files with 56 additions and 5 deletions

View File

@@ -2072,7 +2072,8 @@
// Create a web server to serve One Client Recovery (OCR) disk image files.
webserver = CreateWebServer();
webserver.generateCertificate();
webserver.start(function () { webserver.setupBootImage('C:\\temp\\ubuntu-18.04-desktop-amd64.iso', '127.0.0.1'); });
//webserver.start(function () { webserver.setupBootImage('C:\\temp\\ubuntu-18.04-desktop-amd64.iso', '127.0.0.1'); });
webserver.start();
webserver.onTransfers = function (webserver, transfers) {
var x = '';
for (var i in transfers) { x += '<div style="width:350px;position:relative;padding:3px"><span style="position:absolute;padding:3px;font-weight:bold">' + transfers[i].xfilename + '</span><div style="height:20px;background-color:#4CAF50;width:' + Math.floor((transfers[i].progress.count * 100) / transfers[i].xsize) + '%;border-radius:4px"></div></div>'; }
@@ -9876,6 +9877,12 @@
addOption('d5actionSelect', "Reset to PXE", 400);
addOption('d5actionSelect', "Power on to PXE", 401);
// ###BEGIN###{PowerControl-Advanced}
// ###BEGIN###{PowerControl-OneClick}
if (amtPowerBootCapabilities['ForceUEFIHTTPSBoot'] == true) {
addOption('d5actionSelect', "Reset to HTTPS Boot", 600);
addOption('d5actionSelect', "Power on to HTTPS Boot", 601);
}
// ###END###{PowerControl-OneClick}
addOption('d5actionSelect', "Custom action...", 999);
// ###END###{PowerControl-Advanced}
if (amtversion > 5) { addOption('d5actionSelect', "User consent...", 998); } // On AMT 5 and higher, offer the option of doing user consent alone.
@@ -9885,8 +9892,31 @@
}
}
// ###BEGIN###{PowerControl-Advanced}
// ###BEGIN###{PowerControl-OneClick}
function oneClickFileSelect() { QE('idx_dlgOkButton', Q('ocrfile').files.length == 1); }
// ###END###{PowerControl-OneClick}
// ###END###{PowerControl-Advanced}
function powerActionDlgCheck() {
var action = d5actionSelect.value;
// ###BEGIN###{PowerControl-Advanced}
// ###BEGIN###{PowerControl-OneClick}
if ((action == 600) || (action == 601)) {
var x = "Select a disk image for remote boot." + '<br /><br /><input id=ocrfile type=file onchange=oneClickFileSelect() accept=".iso">';
setDialogMode(11, "HTTPS Boot", 3, function () {
var files = Q('ocrfile').files;
if (files.length != 1) return;
webserver.setupBootImage(files[0].path, wsstack.comm.socket.localAddress);
powerActionDlg();
}, x);
QE('idx_dlgOkButton', false);
return;
}
// ###END###{PowerControl-OneClick}
// ###END###{PowerControl-Advanced}
if ((action == 500) || (action == 501)) {
// Perform OS wake from standby or OS sleep (Intel AMT 10+)
amtstack.RequestOSPowerStateChange((action == 501)?3:2, function (stack, name, response, status) {
@@ -10183,7 +10213,17 @@
rsepass = null;
// ###BEGIN###{PowerControl-Advanced}
}
// ###BEGIN###{PowerControl-OneClick}
// Add OCR TLV parameters if firmware supports OCR and Force HTTPS Boot is requested
if ((action == 600) || (action == 601)) { // Force UEFI HTTPS Boot
r['UefiBootParametersArray'] = webserver.lastBootImageArgs.args;
r['UefiBootNumberOfParams'] = webserver.lastBootImageArgs.argscount;
r['BootMediaIndex'] = 0; // Do not use boot media index for One Click Recovery (OCR)
}
// ###END###{PowerControl-OneClick}
// ###END###{PowerControl-Advanced}
//if (((action == 104) || (action == 105)) && !r['SecureErase']) { /*console.log("This Intel&reg; AMT does not support Secure Erase");*/ cleanup(); return; }
console.log("Boot Action: " + action);
console.log("Setting Boot Settings: " + ObjectToString2(r));
@@ -10206,13 +10246,22 @@
var action = d5actionSelect.value, bootSource = null;
// ###BEGIN###{PowerControl-Advanced}
if (action == 999) {
// ###BEGIN###{!PowerControl-OneClick}
if (idx_d24ForceBootDevice.value > 0) { bootSource = ['Force CD/DVD Boot', 'Force PXE Boot', 'Force Hard-drive Boot', 'Force Diagnostic Boot'][idx_d24ForceBootDevice.value - 1]; }
// ###END###{!PowerControl-OneClick}
// ###BEGIN###{PowerControl-OneClick}
if (idx_d24ForceBootDevice.value > 0) { bootSource = ['Force CD/DVD Boot', 'Force PXE Boot', 'Force Hard-drive Boot', 'Force Diagnostic Boot', 'Force OCR UEFI Boot Option ' + Q('idx_d24BootMediaIndex').value, 'Force OCR UEFI HTTPS Boot'][idx_d24ForceBootDevice.value - 1]; }
// ###END###{PowerControl-OneClick}
} else {
// ###END###{PowerControl-Advanced}
if (action == 300 || action == 301) { bootSource = 'Force Diagnostic Boot'; }
if (action == 400 || action == 401) { bootSource = 'Force PXE Boot'; }
// ###BEGIN###{PowerControl-Advanced}
// ###BEGIN###{PowerControl-Advanced}
}
// Resetting Force boot data in case it was changed so that it won't be used on the next power action
Q('idx_d24ForceBootDevice').value = 0;
// ###END###{PowerControl-Advanced}
console.log('ChangeBootOrder: ' + bootSource);
amtstack.CIM_BootConfigSetting_ChangeBootOrder((bootSource == null)?bootSource:'<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://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">Intel(r) AMT: ' + bootSource + '</Selector></SelectorSet></ReferenceParameters>', powerActionResponse3);
@@ -10225,8 +10274,8 @@
//console.log("Performing Power State Change...");
statusbox("Power Action", "Performing power action...");
var action = d5actionSelect.value;
if (action == 100 || action == 201 || action == 203 || action == 300 || action == 401) action = 2; // Power up
if (action == 101 || action == 200 || action == 202 || action == 301 || action == 400) action = 10; // Reset
if (action == 100 || action == 201 || action == 203 || action == 300 || action == 401 || action == 601) action = 2; // Power up
if (action == 101 || action == 200 || action == 202 || action == 301 || action == 400 || action == 600) action = 10; // Reset
if (action == 104) action = 2; // Power on with Remote Secure Erase
if (action == 105) action = 10; // Reset with Remote Secure Erase
// ###BEGIN###{PowerControl-Advanced}

View File

@@ -22,6 +22,7 @@ var CreateWebServer = function () {
obj.transfers = []; // List of currently active file transfers.
obj.transfersTimer = null; // When file transfers are active, this is a half second timer.
obj.onTransfers = null; // Callback for transfers status.
obj.lastBootImageArgs = null;
// Return a random number between min and max
function random(min, max) { return Math.floor(min + Math.random() * (max - min)); }
@@ -135,7 +136,7 @@ var CreateWebServer = function () {
var name = ('' + Math.random()).substring(2);
obj.responses['/' + name] = { type: 'application/octet-stream', file: filePath };
console.log('https://' + ip + ':' + obj.port + '/' + name);
return {
obj.lastBootImageArgs = {
args: btoa(
makeUefiBootParam(1, 'http' + ((obj.cert != null)?'s':'') + '://' + ip + ':' + obj.port + '/' + name) + // OCR_EFI_NETWORK_DEVICE_PATH
makeUefiBootParam(20, 0, 1) + // OCR_HTTPS_CERT_SYNC_ROOT_CA
@@ -143,6 +144,7 @@ var CreateWebServer = function () {
makeUefiBootParam(30, 60, 2)), // OCR_HTTPS_REQUEST_TIMEOUT (60 seconds)
argscount: 4
};
return obj.lastBootImageArgs;
}
return obj;