
images.firefox.mozilla.cfg Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tls-docker-library Show documentation
Show all versions of tls-docker-library Show documentation
Bill of Materials POM for the entire protocol attacker ecosystem used to keep dependencies in sync.
The newest version!
// This imports a root certificate into Firefox
// The certificate has to be in defaults/pref directory of Firefox
// Source : http://xulfr.org/forums/read.php?1,8256
function importCert(certFileName) {
var BEGIN_CERT = "-----BEGIN CERTIFICATE-----";
var END_CERT = "-----END CERTIFICATE-----";
var x509certdb = Components.classes["@mozilla.org/security/x509certdb;1"];
var certDB ;
try {
// For Firefox <=32
certDB = x509certdb.getService(Components.interfaces.nsIX509CertDB2);
}
catch (exc) {
// For Firefox >=33
certDB = x509certdb.getService(Components.interfaces.nsIX509CertDB);
}
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var scriptableStream = Components.classes["@mozilla.org/scriptableinputstream;1"]
.getService(Components.interfaces.nsIScriptableInputStream);
// https://developer.mozilla.org/en-US/Add-ons/Code_snippets/File_I_O#Getting_special_files
Components.utils.import("resource://gre/modules/FileUtils.jsm");
var certFile = FileUtils.getFile("PrfDef", [certFileName]);
// http://www.mozilla.org/projects/security/pki/nss/tools/certutil.html
var trustFlags = "C,C,C";
var channel = ioService.newChannelFromURI(ioService.newFileURI(certFile));
var input = channel.open();
scriptableStream.init(input);
var certfile = scriptableStream.read(input.available());
scriptableStream.close();
input.close();
certfile = certfile.replace(/[\r\n]/g, "");
begin = certfile.indexOf(BEGIN_CERT);
end = certfile.indexOf(END_CERT);
cert = certfile.substring(begin + BEGIN_CERT.length, end);
certDB.addCertFromBase64(cert, trustFlags, "");
}
importCert("ca.pem");
© 2015 - 2025 Weber Informatics LLC | Privacy Policy