Failure while calling nsIX509CertDB.nsIX509CertDB

2019-08-26 19:35发布

I'm trying to develop a FF extension that calls nsIX509CertDB.nsIX509CertDB. When calling this function from a xpcshell I alwas receive a error 0x80004005 (NS_ERROR_FAILURE). I suspect it to be failing since in a xpcshell environment I can not be prompted for the password. Is there any way to provide it from the command line?

My code:

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

1条回答
相关推荐>>
2楼-- · 2019-08-26 19:59

This would most likely involve writing code to replace @mozilla.org/nsCertificateDialogs;1 component (implementing nsICertificateDialogs interface). Then you could implement getPKCS12FilePassword method any way you like.

The simpler approach would be using pk12util tool included in NSS. Unless this really needs to be done via xpcshell of course.

查看更多
登录 后发表回答