shelve
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
26a27a6de4
commit
38e7a9b0f8
2 changed files with 56 additions and 0 deletions
|
@ -28,6 +28,7 @@ const AutoLaunch = require('auto-launch');
|
||||||
|
|
||||||
const tray = require('./tray');
|
const tray = require('./tray');
|
||||||
const vectorMenu = require('./vectormenu');
|
const vectorMenu = require('./vectormenu');
|
||||||
|
const trustCertificate = require('./trust-certificate');
|
||||||
const webContentsHandler = require('./webcontents-handler');
|
const webContentsHandler = require('./webcontents-handler');
|
||||||
|
|
||||||
const windowStateKeeper = require('electron-window-state');
|
const windowStateKeeper = require('electron-window-state');
|
||||||
|
@ -290,6 +291,7 @@ electron.app.on('ready', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
webContentsHandler(mainWindow.webContents);
|
webContentsHandler(mainWindow.webContents);
|
||||||
|
trustCertificate.register(mainWindow);
|
||||||
mainWindowState.manage(mainWindow);
|
mainWindowState.manage(mainWindow);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
54
electron_app/src/trust-certificate.js
Normal file
54
electron_app/src/trust-certificate.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/**
|
||||||
|
* Created by t3chg on 22/06/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const {app, dialog} = require('electron');
|
||||||
|
|
||||||
|
module.exports = {};
|
||||||
|
|
||||||
|
const certificates = [];
|
||||||
|
|
||||||
|
module.exports.register = function(browserWindow) {
|
||||||
|
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
|
||||||
|
if (certificates.includes(certificate.fingerprint)) {
|
||||||
|
event.preventDefault();
|
||||||
|
callback(true);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((process.platform === 'darwin' || process.platform === 'win32') && false) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// dialog.showCertificateTrustDialog(browserWindow, { certificate, message: 'Would you like to ignore this?' }, () => {});
|
||||||
|
dialog.showMessageBox(browserWindow, {
|
||||||
|
type: 'warning',
|
||||||
|
buttons: [
|
||||||
|
'Yes',
|
||||||
|
'No',
|
||||||
|
],
|
||||||
|
defaultId: 0,
|
||||||
|
title: 'SSL Certificate Error',
|
||||||
|
message: 'Would you like to trust this cert anyway?',
|
||||||
|
detail: error + '\n'
|
||||||
|
+ 'Fingerprint: ' + certificate.fingerprint + '\n'
|
||||||
|
+ 'Subject Name: ' + certificate.subjectName + '\n'
|
||||||
|
+ 'Issuer Name: ' + certificate.issuerName + '\n'
|
||||||
|
+ 'Serial: ' + certificate.serialNumber,
|
||||||
|
cancelId: 1,
|
||||||
|
|
||||||
|
}, function(response, _) {
|
||||||
|
console.log(response);
|
||||||
|
if (response === 0) {
|
||||||
|
certificates.push(certificate.fingerprint);
|
||||||
|
console.log(certificates);
|
||||||
|
event.preventDefault();
|
||||||
|
callback(true);
|
||||||
|
} else {
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue