diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index cd149f9cfde1..0d1f6a71782b 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -212,6 +212,7 @@ struct Converter { dict.Set("hostname", val.hostname); dict.Set("certificate", val.certificate); dict.Set("verificationResult", val.default_result); + dict.Set("errorCode", val.error_code); return dict.GetHandle(); } }; diff --git a/atom/browser/net/atom_cert_verifier.cc b/atom/browser/net/atom_cert_verifier.cc index 2a2229f19d1f..9cc4a6132615 100644 --- a/atom/browser/net/atom_cert_verifier.cc +++ b/atom/browser/net/atom_cert_verifier.cc @@ -92,6 +92,7 @@ class CertVerifierRequest : public AtomCertVerifier::Request { std::unique_ptr request(new VerifyRequestParams()); request->hostname = params_.hostname(); request->default_result = net::ErrorToString(error); + request->error_code = error; request->certificate = params_.certificate(); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, diff --git a/atom/browser/net/atom_cert_verifier.h b/atom/browser/net/atom_cert_verifier.h index 09fa0f2778e8..76382bf4c5d4 100644 --- a/atom/browser/net/atom_cert_verifier.h +++ b/atom/browser/net/atom_cert_verifier.h @@ -19,6 +19,7 @@ class CertVerifierRequest; struct VerifyRequestParams { std::string hostname; std::string default_result; + int error_code; scoped_refptr certificate; }; diff --git a/docs/api/session.md b/docs/api/session.md index 34fd8c481d54..25ca1b3a8242 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -253,7 +253,8 @@ the original network configuration. * `request` Object * `hostname` String * `certificate` [Certificate](structures/certificate.md) - * `error` String - Verification result from chromium. + * `verificationResult` String - Verification result from chromium. + * `errorCode` Integer - Error code. * `callback` Function * `verificationResult` Integer - Value can be one of certificate error codes from [here](https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h). diff --git a/spec/api-session-spec.js b/spec/api-session-spec.js index d361c10d947e..51996d448b3c 100644 --- a/spec/api-session-spec.js +++ b/spec/api-session-spec.js @@ -572,8 +572,9 @@ describe('session module', function () { }) it('accepts the request when the callback is called with 0', function (done) { - session.defaultSession.setCertificateVerifyProc(function ({hostname, certificate, verificationResult}, callback) { + session.defaultSession.setCertificateVerifyProc(function ({hostname, certificate, verificationResult, errorCode}, callback) { assert(['net::ERR_CERT_AUTHORITY_INVALID', 'net::ERR_CERT_COMMON_NAME_INVALID'].includes(verificationResult), verificationResult) + assert([-202, -200].includes(errorCode), errorCode) callback(0) })