You seem to be coding in JavaScript. Looking at the DB interface, the import cert functions are marked as [noscript], which means it's not possible to access them from JS.
If you need a solution 1.0x, I fear you'll have to code it using C++.
Kai
Schuyler Duveen wrote:
Apologies, in advance if this has been covered.
The importCertsFromFile method seems to have been implemented after the mozilla 1.0x tree. Is there a workaround to this using the nsIX509CertDB interface for Mozilla 1.0?
Basically, I am creating a configuration plugin that downloads the certificate to the Profile directory, and then upon restarting the client, the plugin walks the user through installing the certificate and other configuration changes (The advantage to a plugin, is that it works for both Netscape 7 AND Mozilla). The relevant code is below, which works for Mozilla 1.2, but not Mozilla 1.0 or Netscape 7.
I can't seem to figure out how to use the nsIX509CertDB.importCertificates() method. Could this work? Can someone point to an example of how this is used?
relevant code:
var certdb =
Components.classes["@mozilla.org/security/x509certdb;1"].getService(Components.interfaces.nsIX509CertDB);
var certdir =
Components.classes["@mozilla.org/file/directory_service;1"].createInstance(Components.interfaces.nsIProperties);
var certfile =certdir.get("ProfD", Components.interfaces.nsILocalFile);
certfile.append("CREN.cer");
if (certfile != null && certfile.exists())
certdb.importCertsFromFile(null, certfile, Components.interfaces.nsIX509Cert.CA_CERT);
else
alert("Cert file does not exist!");
