Created
March 10, 2017 16:05
-
-
Save friegger/1ca27e2becba645e41c1a22ed65f0982 to your computer and use it in GitHub Desktop.
Handling cert errors in electron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
B.fromEvent(app, 'certificate-error', (event, webContents, url, error, certificate, callback) => { | |
return [event, webContents, url, error, certificate, callback] | |
}).onValue(args => { | |
dialog.showMessageBox({ | |
type: 'warning', | |
title: 'Certificate Error', | |
buttons: ['Proceed', 'Back to Safty'], | |
message: `The certificate for ${args[2]} is invalid.`, | |
detail: args[3] | |
}, (index) => { | |
console.log('Index', index) | |
switch(index) { | |
case 0: | |
console.log('Allowing') | |
args[0].preventDefault() | |
args[5](true) | |
break; | |
default: | |
args[5](false) | |
} | |
}) | |
// console.log(args[1].hostWebContents.loadURL('https://heise.de')) | |
// console.log(args[2]) | |
args[0].preventDefault() | |
// args[5](false) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment