]> khamidou — GitHub mirrors - electron.git/commitdiff
docs: Update the certificate APIs
authorCheng Zhao <zcbenz@gmail.com>
Wed, 18 Nov 2015 03:35:26 +0000 (11:35 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 18 Nov 2015 03:35:26 +0000 (11:35 +0800)
atom/browser/api/atom_api_app.cc
docs/api/app.md
docs/api/session.md
docs/api/web-contents.md

index 73f4b39277289c6bb78d24f3cb7bd3caf9e77c67..28c3b4c1598349c09d3afa05bf9515fcc7426d9c 100644 (file)
@@ -252,7 +252,7 @@ void App::AllowCertificateError(
   bool prevent_default = Emit("certificate-error",
                               WebContents::CreateFrom(isolate(), web_contents),
                               request_url,
-                              cert_error,
+                              net::ErrorToString(cert_error),
                               ssl_info.cert,
                               callback);
 
index 4ff90f3e5785c3f9a5a00f5c49760684d421db3a..d7850c4cb92cd701a22aef7ec3dad58e991d5ec2 100644 (file)
@@ -131,6 +131,35 @@ Returns:
 
 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:
index e385e222d5291a5de9fed514fbb4a0b04f0b3649..450be7b08e113b27879973e73d4333858d1b2c47 100644 (file)
@@ -34,31 +34,6 @@ session.on('will-download', function(event, item, webContents) {
 });
 ```
 
-### 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:
@@ -245,3 +220,24 @@ window.webContents.session.enableNetworkEmulation({offline: true});
 
 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);
+});
+```
index 0988d25276f4f2fcbd803b7b54283855cb35ba1f..be22d947c7524e117fb6394ba25b0c1167cbe759 100644 (file)
@@ -167,6 +167,39 @@ Emitted when DevTools is closed.
 
 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: