1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
9 XPCOMUtils.defineLazyServiceGetter(
12 "@mozilla.org/ssservice;1",
13 "nsISiteSecurityService"
16 XPCOMUtils.defineLazyServiceGetter(
18 "certOverrideService",
19 "@mozilla.org/security/certoverride;1",
20 "nsICertOverrideService"
23 const CERT_PINNING_ENFORCEMENT_PREF = "security.cert_pinning.enforcement_level";
24 const HSTS_PRELOAD_LIST_PREF = "network.stricttransportsecurity.preloadlist";
27 export const allowAllCerts = {};
30 * Disable all security check and allow all certs.
32 allowAllCerts.enable = function () {
33 // make it possible to register certificate overrides for domains
34 // that use HSTS or HPKP
35 Services.prefs.setBoolPref(HSTS_PRELOAD_LIST_PREF, false);
36 Services.prefs.setIntPref(CERT_PINNING_ENFORCEMENT_PREF, 0);
38 lazy.certOverrideService.setDisableAllSecurityChecksAndLetAttackersInterceptMyData(
44 * Enable all security check.
46 allowAllCerts.disable = function () {
47 lazy.certOverrideService.setDisableAllSecurityChecksAndLetAttackersInterceptMyData(
51 Services.prefs.clearUserPref(HSTS_PRELOAD_LIST_PREF);
52 Services.prefs.clearUserPref(CERT_PINNING_ENFORCEMENT_PREF);
54 // clear collected HSTS and HPKP state
55 // through the site security service