Emit verify-certificate only when default verifier fails
This commit is contained in:
parent
e3517b701e
commit
ebe66daa56
4 changed files with 65 additions and 68 deletions
|
@ -21,7 +21,7 @@ var session = win.webContents.session
|
|||
* `item` [DownloadItem](download-item.md)
|
||||
* `webContents` [WebContents](web-contents.md)
|
||||
|
||||
Fired when Electron is about to download `item` in `webContents`.
|
||||
Emitted when Electron is about to download `item` in `webContents`.
|
||||
|
||||
Calling `event.preventDefault()` will cancel the download.
|
||||
|
||||
|
@ -43,18 +43,19 @@ session.on('will-download', function(event, item, webContents) {
|
|||
* `issuerName` String
|
||||
* `callback` Function
|
||||
|
||||
Fired whenever a server certificate verification is requested by the
|
||||
network layer with `hostname`, `certificate` and `callback`.
|
||||
`callback` should be called with a boolean response to
|
||||
indicate continuation or cancellation of the request.
|
||||
Emitted when failed to verify the `certificate` for `hostname`, to trust the
|
||||
certificate you should prevent the default behavior with
|
||||
`event.preventDefault()` and call `callback(true)`.
|
||||
|
||||
```js
|
||||
session.on('verify-certificate', function(event, hostname, certificate, callback) {
|
||||
if (hostname == "github.com") {
|
||||
// verification logic
|
||||
// Verification logic.
|
||||
event.preventDefault();
|
||||
callback(true);
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
callback(false);
|
||||
});
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue