1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/publicdomain/zero/1.0/
5 // Tests that use a mock builtins module.
7 // Ensure that the appropriate initialization has happened.
9 const gCertDb = Cc["@mozilla.org/security/x509certdb;1"].getService(
13 add_setup(function load_nssckbi_testlib() {
14 let moduleName = "Mock Builtins";
15 let libraryName = "test_builtins";
17 checkPKCS11ModuleNotPresent(moduleName, libraryName);
19 let libraryFile = Services.dirsvc.get("CurWorkD", Ci.nsIFile);
20 libraryFile.append("test_builtins");
21 libraryFile.append(ctypes.libraryName(libraryName));
22 loadPKCS11Module(libraryFile, moduleName, true);
23 let testModule = checkPKCS11ModuleExists(moduleName, libraryName);
25 // Check that listing the slots for the test module works.
26 let testModuleSlotNames = Array.from(
27 testModule.listSlots(),
30 testModuleSlotNames.sort();
31 const expectedSlotNames = ["NSS Builtin Objects"];
35 "Actual and expected slot names should be equal"
39 add_task(async function test_distrust_after() {
40 let ee_pre_distrust_cert = addCertFromFile(
42 "test_builtins/ee-notBefore-2021.pem",
48 "EE cert should have successfully loaded"
51 let ee_post_distrust_cert = addCertFromFile(
53 "test_builtins/ee-notBefore-2023.pem",
57 ee_post_distrust_cert,
59 "EE cert should have successfully loaded"
62 let int_cert = addCertFromFile(gCertDb, "test_builtins/int.pem", ",,");
63 notEqual(int_cert, null, "Intermediate cert should have successfully loaded");
65 // A certificate with a notBefore before the distrustAfter date
67 await checkCertErrorGeneric(
71 certificateUsageSSLServer
74 // A certificate with a notBefore after the distrustAfter date
76 await checkCertErrorGeneric(
78 ee_post_distrust_cert,
79 MOZILLA_PKIX_ERROR_ISSUER_NO_LONGER_TRUSTED,
80 certificateUsageSSLServer