Files
firefox/security/manager/ssl/tests/unit/test_missing_intermediate.js
T
David Keeler 91fd4bf7e6 bug 1364159 - potentially avoid calling CERT_CreateSubjectCertList in NSSCertDBTrustDomain::FindIssuer r=Cykesiopka,jcj
CERT_CreateSubjectCertList is not an inexpensive function call, since it
enumerates the certificate database (i.e. reads from disk a lot). If we're
verifying for a TLS handshake, however, we should already have in memory a
certificate chain sent by the peer (there are some cases where we won't, such as
session resumption (see bug 731478)). If we can, we should use those
certificates before falling back to calling CERT_CreateSubjectCertList.

MozReview-Commit-ID: ASjVGsELb1O
2017-05-11 16:41:12 -07:00

31 lines
1.2 KiB
JavaScript

// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
"use strict";
// Tests that if a server does not send a complete certificate chain, we can
// make use of cached intermediates to build a trust path.
do_get_profile(); // must be called before getting nsIX509CertDB
const certdb = Cc["@mozilla.org/security/x509certdb;1"]
.getService(Ci.nsIX509CertDB);
function run_test() {
addCertFromFile(certdb, "bad_certs/test-ca.pem", "CTu,,");
add_tls_server_setup("BadCertServer", "bad_certs");
// If we don't know about the intermediate, we'll get an unknown issuer error.
add_connection_test("ee-from-missing-intermediate.example.com",
SEC_ERROR_UNKNOWN_ISSUER);
add_test(() => {
addCertFromFile(certdb, "test_missing_intermediate/missing-intermediate.pem",
",,");
run_next_test();
});
// Now that we've cached the intermediate, the connection should succeed.
add_connection_test("ee-from-missing-intermediate.example.com",
PRErrorCodeSuccess);
run_next_test();
}