Skip to content

Instantly share code, notes, and snippets.

@friegger
Created March 10, 2017 16:05
Show Gist options
  • Save friegger/1ca27e2becba645e41c1a22ed65f0982 to your computer and use it in GitHub Desktop.
Save friegger/1ca27e2becba645e41c1a22ed65f0982 to your computer and use it in GitHub Desktop.
Handling cert errors in electron
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