session: api to allow handling certificate verification
This commit is contained in:
parent
ce0167756e
commit
d072e61282
14 changed files with 231 additions and 17 deletions
|
@ -139,8 +139,8 @@ Returns:
|
|||
* `webContents` [WebContents](web-contents.md)
|
||||
* `url` URL
|
||||
* `certificateList` [Objects]
|
||||
* `data` PEM encoded data
|
||||
* `issuerName` Issuer's Common Name
|
||||
* `data` Buffer - PEM encoded data
|
||||
* `issuerName` String - Issuer's Common Name
|
||||
* `callback` Function
|
||||
|
||||
Emitted when a client certificate is requested.
|
||||
|
|
|
@ -220,3 +220,34 @@ 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`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue