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
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 /* import-globals-from pippki.js */
7 var gCertDB = Cc["@mozilla.org/security/x509certdb;1"].getService(
11 * Cert to edit the trust of.
15 var gCert = window.arguments[0];
17 document.addEventListener("DOMContentLoaded", init);
20 document.addEventListener("dialogaccept", onDialogAccept);
22 let sslCheckbox = document.getElementById("trustSSL");
23 sslCheckbox.checked = gCertDB.isCertTrusted(
25 Ci.nsIX509Cert.CA_CERT,
26 Ci.nsIX509CertDB.TRUSTED_SSL
29 let emailCheckbox = document.getElementById("trustEmail");
30 emailCheckbox.checked = gCertDB.isCertTrusted(
32 Ci.nsIX509Cert.CA_CERT,
33 Ci.nsIX509CertDB.TRUSTED_EMAIL
36 let certMsg = document.getElementById("certmsg");
37 document.l10n.setAttributes(certMsg, "edit-trust-ca", {
38 certName: gCert.commonName,
43 * ondialogaccept() handler.
45 function onDialogAccept() {
46 let sslCheckbox = document.getElementById("trustSSL");
47 let emailCheckbox = document.getElementById("trustEmail");
48 let trustSSL = sslCheckbox.checked ? Ci.nsIX509CertDB.TRUSTED_SSL : 0;
49 let trustEmail = emailCheckbox.checked ? Ci.nsIX509CertDB.TRUSTED_EMAIL : 0;
51 gCertDB.setCertTrust(gCert, Ci.nsIX509Cert.CA_CERT, trustSSL | trustEmail);