From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../manager/pki/resources/content/editcacert.js | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 security/manager/pki/resources/content/editcacert.js (limited to 'security/manager/pki/resources/content/editcacert.js') diff --git a/security/manager/pki/resources/content/editcacert.js b/security/manager/pki/resources/content/editcacert.js new file mode 100644 index 0000000000..c482bd6e0a --- /dev/null +++ b/security/manager/pki/resources/content/editcacert.js @@ -0,0 +1,55 @@ +/* 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/. */ +/* import-globals-from pippki.js */ +"use strict"; + +var gCertDB = Cc["@mozilla.org/security/x509certdb;1"].getService( + Ci.nsIX509CertDB +); +/** + * Cert to edit the trust of. + * + * @type {nsIX509Cert} + */ +var gCert; + +/** + * onload() handler. + */ +function onLoad() { + gCert = window.arguments[0]; + + document.addEventListener("dialogaccept", onDialogAccept); + + let certMsg = document.getElementById("certmsg"); + document.l10n.setAttributes(certMsg, "edit-trust-ca", { + certName: gCert.commonName, + }); + + let sslCheckbox = document.getElementById("trustSSL"); + sslCheckbox.checked = gCertDB.isCertTrusted( + gCert, + Ci.nsIX509Cert.CA_CERT, + Ci.nsIX509CertDB.TRUSTED_SSL + ); + + let emailCheckbox = document.getElementById("trustEmail"); + emailCheckbox.checked = gCertDB.isCertTrusted( + gCert, + Ci.nsIX509Cert.CA_CERT, + Ci.nsIX509CertDB.TRUSTED_EMAIL + ); +} + +/** + * ondialogaccept() handler. + */ +function onDialogAccept() { + let sslCheckbox = document.getElementById("trustSSL"); + let emailCheckbox = document.getElementById("trustEmail"); + let trustSSL = sslCheckbox.checked ? Ci.nsIX509CertDB.TRUSTED_SSL : 0; + let trustEmail = emailCheckbox.checked ? Ci.nsIX509CertDB.TRUSTED_EMAIL : 0; + + gCertDB.setCertTrust(gCert, Ci.nsIX509Cert.CA_CERT, trustSSL | trustEmail); +} -- cgit v1.2.3