从firefox扩展中替换nsICertificateDialogs [英] replace nsICertificateDialogs from firefox extension

查看:197
本文介绍了从firefox扩展中替换nsICertificateDialogs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用我自己的实现替换 nsICertificateDialogs 对话框。我已经有一个扩展,处理smime邮件从webmail。我想能够使用我的扩展名的Mozilla证书存储。我发现导出smime证书/密钥(在我的扩展中使用它)的唯一可能性是通过导出一个pfx文件。



我注销原始证书和注册的地址,如此处所述从命令行调用nsIX509CertDB.nsIX509CertDB时失败< a>(注销旧工厂并使用正确的contractID注册我的)。当我调用 Cc [@ mozilla.org / nsCertificateDialogs; 1] .getService(Ci.nsICertificateDialogs); 我的类被实例化。当调用 certDB.importPKCS12File(null,certfile)我得到一个 NS_ERROR_FAILURE ,我的对话框类不实例化。 p>

当FF实例化证书对话框时有什么区别。我该如何测试呢?我缺少什么?



编辑:我的证书对话框类不是由ff实现的 - 即使用有效的令牌certDB.importPKCS12File(token,certfile)调用。在更改中调用var certdialogInterface = Cc [sMimeCertificateDialog.mozillaContractID] .getService(Ci.nsICertificateDialogs);正确地实现我的类(后面跟一些QueryInterface调用)



编辑:我上传了一个(希望)简单的再现器到 http://www.sodgeit.de/dialog_reproducer.zip 查看src / chrome / components / smime_certificate_dialog.js和src / tests / smime_certificate_dialog_test.js

解决方案


当FF实例化证书对话框时有什么区别。


实际上没有差别。当Firefox需要文件密码时,它会调用 getNSSDialogs()函数,并且会执行您的 getService()调用的道德等同物。但是, getService()仅第一次实例化组件,后续调用不会再导致实例化 - 这可能是为什么没有看到任何来自Firefox代码。



另一个潜在的问题是,你没有传递任何令牌到函数。这意味着Firefox将尝试确定令牌本身并调用 GetSlotWithMechanism() 。在多个可用的令牌的情况下,它将显示一个选择对话框,它将基本上调用 Cc [@ mozilla.org/nsTokenDialogs;1\"].getService(Ci.nsITokenDialogs).ChooseToken()。所以也许它的错误出来,因为这个组件不能在你的xpcshell中使用 - 意味着你将不得不替换它或明确指定一个标记。


I'm trying to replace the nsICertificateDialogs dialog with my own implementation. I already have an extension that handles smime mails from webmail. I want to be able to use the Mozilla cert store with my extension. The only possibility I've found to export smime certs/keys (to use it in my extension) is via exporting a pfx file.

I unregistered the original certifica tedialog and registered mine as described here Failure while calling nsIX509CertDB.nsIX509CertDB from command line (unregister the old factory and register mine with the correct contractID). When I call Cc[@mozilla.org/nsCertificateDialogs;1].getService(Ci.nsICertificateDialogs); my class gets instantiated. When calling certDB.importPKCS12File(null, certfile) I get an NS_ERROR_FAILURE and my dialog class is not instantiated.

What is the difference when FF instantiates the certificate dialog. How can I test it? What am I missing?

edit: my certificate dialog class does not get instanciated by ff - even when called with a valid token certDB.importPKCS12File(token, certfile); In change calling var certdialogInterface = Cc[sMimeCertificateDialog.mozillaContractID] .getService(Ci.nsICertificateDialogs); correctly instanciates my class (followed by some QueryInterface calls)

edit: I uploaded a (hopefully) simple reproducer to http://www.sodgeit.de/dialog_reproducer.zip Look at src/chrome/components/smime_certificate_dialog.js and at src/tests/smime_certificate_dialog_test.js

解决方案

What is the difference when FF instantiates the certificate dialog.

No difference actually. When Firefox need the file password it will call getNSSDialogs() function and that one will do the moral equivalent of your getService() call. However, getService() only instantiates the component the first time, subsequent calls would not cause instantiation again - this might be the explanation why you don't see any coming from Firefox code.

The other potential issue is that you are not passing any token to the function. This means that Firefox will try to determine the token itself and call GetSlotWithMechanism(). In case of multiple available tokens it will display a selection dialog, it will basically call Cc["@mozilla.org/nsTokenDialogs;1"].getService(Ci.nsITokenDialogs).ChooseToken(). So maybe it errors out because this component isn't usable in your xpcshell - meaning that you would have to either replace it as well or specify a token explicitly.

这篇关于从firefox扩展中替换nsICertificateDialogs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆