mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
session: api to allow handling certificate verification
This commit is contained in:
@@ -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`.
|
||||
|
||||
Reference in New Issue
Block a user