1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 // This file tests that cert_storage correctly persists its information across
8 // runs of the browser specifically in the case of CRLite.
9 // (The test DB files for this test were created by running the test
10 // `test_cert_storage_direct.js` and copying them from that test's profile
13 /* eslint-disable no-unused-vars */
14 add_task(async function () {
15 Services.prefs.setIntPref(
16 "security.pki.crlite_mode",
17 CRLiteModeEnforcePrefValue
20 let dbDirectory = do_get_profile();
21 dbDirectory.append("security_state");
22 let crliteFile = do_get_file(
23 "test_cert_storage_preexisting_crlite/crlite.filter"
25 crliteFile.copyTo(dbDirectory, "crlite.filter");
26 let coverageFile = do_get_file(
27 "test_cert_storage_preexisting_crlite/crlite.coverage"
29 coverageFile.copyTo(dbDirectory, "crlite.coverage");
30 let enrollmentFile = do_get_file(
31 "test_cert_storage_preexisting_crlite/crlite.enrollment"
33 enrollmentFile.copyTo(dbDirectory, "crlite.enrollment");
35 let certStorage = Cc["@mozilla.org/security/certstorage;1"].getService(
39 // Add an empty stash to ensure the filter is considered to be fresh.
40 await new Promise(resolve => {
41 certStorage.addCRLiteStash(new Uint8Array([]), (rv, _) => {
42 Assert.equal(rv, Cr.NS_OK, "marked filter as fresh");
47 let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
50 let validCertIssuer = constructCertFromFile(
51 "test_cert_storage_direct/valid-cert-issuer.pem"
53 let validCert = constructCertFromFile(
54 "test_cert_storage_direct/valid-cert.pem"
56 await checkCertErrorGenericAtTime(
60 certificateUsageSSLServer,
61 new Date("2019-10-28T00:00:00Z").getTime() / 1000,
64 Ci.nsIX509CertDB.FLAG_LOCAL_ONLY
67 let revokedCertIssuer = constructCertFromFile(
68 "test_cert_storage_direct/revoked-cert-issuer.pem"
70 let revokedCert = constructCertFromFile(
71 "test_cert_storage_direct/revoked-cert.pem"
73 await checkCertErrorGenericAtTime(
76 SEC_ERROR_REVOKED_CERTIFICATE,
77 certificateUsageSSLServer,
78 new Date("2019-11-04T00:00:00Z").getTime() / 1000,
81 Ci.nsIX509CertDB.FLAG_LOCAL_ONLY