emit verify-certificate event for handling verification

This commit is contained in:
Robo
2015-11-13 01:25:23 +05:30
parent d072e61282
commit 37e6e6fab7
8 changed files with 313 additions and 93 deletions

View File

@@ -34,6 +34,30 @@ session.on('will-download', function(event, item, webContents) {
});
```
### Event: 'verify-certificate'
* `event` Event
* `hostname` String
* `certificate` Object
* `data` Buffer - PEM encoded data
* `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.
```js
session.on('verify-certificate', function(event, hostname, certificate, callback) {
if (hostname == "github.com") {
// verification logic
callback(true);
}
callback(false);
});
```
## Methods
The `session` object has the following methods:
@@ -220,34 +244,3 @@ window.webContents.session.enableNetworkEmulation({offline: true});
Disables any network emulation already active for the `session`. Resets to
the original network configuration.
### `session.setCertificateVerifier(handler)`
* `handler` Function
* `hostname` String
* `certificate` Object
* `data` Buffer - PEM encoded data
* `issuerName` String
* `callback` Function
Sets the certificate verifier for the `session`, will be called
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.
```js
var handler = function(hostname, certificate, callback) {
if (hostname == "github.com") {
// verification logic
callback(true)
}
callback(false)
}
window.webContents.session.setCertificateVerifier(handler)
```
### `session.removeCertificateVerifier()`
Removes the certificate verifier provided for the `session`.