Firefox Addon PKCS#11 API

落爺英雄遲暮 提交于 2019-12-12 10:05:28

问题


I want to access the currenly connected cryptography modules via an Firefox Addon.

I found some interfaces that look like i can access the module, the slot and the token (1 → 2 → 3 → 4) but how can i access the public key of an certificate stored on such a token?

Is there an such an API even available to an Addon?


回答1:


nsIX509CertDB.idl provides the means to access all stored certificates, therefore also the ones accessed through crypto modules. To filter the certificates using the tokenName property should work.

Here is a snippet to enumerate all certs:

var certDB = chrome.Cc["@mozilla.org/security/x509certdb;1"].getService(chrome.Ci.nsIX509CertDB);

var certs = certDB.getCerts();

var enumerator = certs.getEnumerator();

var s = "";
while (enumerator.hasMoreElements()) {
  var cert = enumerator.getNext().QueryInterface(chrome.Ci.nsIX509Cert);

  if (cert.tokenName.equals("Your-token-name"))   
  s += cert.tokenName + " # ";
}

The name of the token can be found through the module name by using: nsIPKCS11ModuleDB.listModules() → nsIPKCS11Module.listSlots() → nsIPKCS11Slot.getToken() → nsIPK11Token.tokenName



来源:https://stackoverflow.com/questions/28817166/firefox-addon-pkcs11-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!