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/.
8 do_get_profile(); // must be called before getting nsIX509CertDB
9 const gCertDB = Cc["@mozilla.org/security/x509certdb;1"].getService(
13 function certFromFile(certName) {
14 return constructCertFromFile(`test_baseline_requirements/${certName}.pem`);
17 function loadCertWithTrust(certName, trustString) {
20 `test_baseline_requirements/${certName}.pem`,
25 function checkCertOn25August2016(cert, expectedResult) {
26 // (new Date("2016-08-25T00:00:00Z")).getTime() / 1000
27 const VALIDATION_TIME = 1472083200;
28 return checkCertErrorGenericAtTime(
32 certificateUsageSSLServer,
39 add_task(async function () {
40 registerCleanupFunction(() => {
41 Services.prefs.clearUserPref("privacy.reduceTimerPrecision");
44 Services.prefs.setBoolPref("privacy.reduceTimerPrecision", false);
46 loadCertWithTrust("ca", "CTu,,");
48 // At one time there was a preference security.pki.name_matching_mode that
49 // controlled whether or not mozilla::pkix would fall back to using a
50 // certificate's subject common name during name matching. This no longer
51 // exists, and certificates that previously required the fallback should fail
54 await checkCertOn25August2016(
55 certFromFile("no-san-recent"),
56 SSL_ERROR_BAD_CERT_DOMAIN
58 await checkCertOn25August2016(
59 certFromFile("no-san-old"),
60 SSL_ERROR_BAD_CERT_DOMAIN
62 await checkCertOn25August2016(
63 certFromFile("no-san-older"),
64 SSL_ERROR_BAD_CERT_DOMAIN
66 await checkCertOn25August2016(
67 certFromFile("san-contains-no-hostnames-recent"),
68 SSL_ERROR_BAD_CERT_DOMAIN
70 await checkCertOn25August2016(
71 certFromFile("san-contains-no-hostnames-old"),
72 SSL_ERROR_BAD_CERT_DOMAIN
74 await checkCertOn25August2016(
75 certFromFile("san-contains-no-hostnames-older"),
76 SSL_ERROR_BAD_CERT_DOMAIN