Error calling nsIX509CertDB.nsIX509CertDB from the command line

I am trying to develop an FF extension that calls nsIX509CertDB.nsIX509CertDB. When calling this function from xpcshell, I get the error 0x80004005 (NS_ERROR_FAILURE). I suspect this is a failure because in the xpcshell environment I cannot request a password. Is there any way to provide it from the command line?

My code is:

if(nsIFile != null && nsIFile.exists()) { var certDB = Cc["@mozilla.org/security/x509certdb;1"] .getService(Ci.nsIX509CertDB); certDB.importPKCS12File(null, nsIFile); } 
0
source share
1 answer

This is most likely due to writing code to replace the @mozilla.org/nsCertificateDialogs;1 component (implementation of the nsICertificateDialogs interface ). Then you can implement the getPKCS12FilePassword method getPKCS12FilePassword any way you like.

A simpler approach is to use the pk12util tool included with NSS. Unless you really need to do this through xpcshell, of course.

+1
source

All Articles