bool prevent_default = Emit("certificate-error",
WebContents::CreateFrom(isolate(), web_contents),
request_url,
- cert_error,
+ net::ErrorToString(cert_error),
ssl_info.cert,
callback);
Emitted when a new [browserWindow](browser-window.md) is created.
+### Event: 'certificate-error'
+
+Returns:
+
+* `event` Event
+* `webContents` [WebContents](web-contents.md)
+* `url` URL
+* `error` String - The error code
+* `certificate` Object
+ * `data` Buffer - PEM encoded data
+ * `issuerName` String
+* `callback` Function
+
+Emitted when failed to verify the `certificate` for `url`, to trust the
+certificate you should prevent the default behavior with
+`event.preventDefault()` and call `callback(true)`.
+
+```javascript
+session.on('certificate-error', function(event, webContents, url, error, certificate, callback) {
+ if (url == "https://github.com") {
+ // Verification logic.
+ event.preventDefault();
+ callback(true);
+ } else {
+ callback(false);
+ }
+});
+```
+
### Event: 'select-client-certificate'
Returns:
});
```
-### Event: 'untrusted-certificate'
-
-* `event` Event
-* `hostname` String
-* `certificate` Object
- * `data` Buffer - PEM encoded data
- * `issuerName` String
-* `callback` Function
-
-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.
- event.preventDefault();
- callback(true);
- } else {
- callback(false);
- }
-});
-```
-
## Methods
The `session` object has the following methods:
Disables any network emulation already active for the `session`. Resets to
the original network configuration.
+
+### `session.setCertificateVerifyProc(proc)`
+
+* `proc` Function
+
+Sets the certificate verify proc for `session`, the `proc` will be called with
+`proc(hostname, certificate, callback)` whenever a server certificate
+verification is requested. Calling `callback(true)` accepts the certificate,
+calling `callback(false)` rejects it.
+
+Calling `setCertificateVerifyProc(null)` will revert back to default certificate
+verify proc.
+
+```javascript
+myWindow.webContents.session.setCertificateVerifyProc(function(hostname, cert, callback) {
+ if (hostname == 'github.com')
+ callback(true);
+ else
+ callback(false);
+});
+```
Emitted when DevTools is focused / opened.
+### Event: 'certificate-error'
+
+Returns:
+
+* `event` Event
+* `url` URL
+* `error` String - The error code
+* `certificate` Object
+ * `data` Buffer - PEM encoded data
+ * `issuerName` String
+* `callback` Function
+
+Emitted when failed to verify the `certificate` for `url`.
+
+The usage is the same with [the `certificate-error` event of
+`app`](app.md#event-certificate-error).
+
+### Event: 'select-client-certificate'
+
+Returns:
+
+* `event` Event
+* `url` URL
+* `certificateList` [Objects]
+ * `data` Buffer - PEM encoded data
+ * `issuerName` String - Issuer's Common Name
+* `callback` Function
+
+Emitted when a client certificate is requested.
+
+The usage is the same with [the `select-client-certificate` event of
+`app`](app.md#event-select-client-certificate).
+
### Event: 'login'
Returns: