pkcs11.getModuleSlots() 编辑

Enumerate a module's slots. This function returns an array containing one entry for each slot. Each entry contains the slot's name and, if the slot contains a token, information about the token.

You can only call this for a module that is installed in Firefox.

This is an asynchronous function that returns a Promise.

Syntax

var getting = browser.pkcs11.getModuleSlots(
  name              // string
)

Parameters

name
string. Name of the module. This must match the name property in the PKCS #11 manifest for the module.

Return value

A Promise that will be fulfilled with an array of objects, one for each slot that the module provides access to. Each object has two properties:

  • name: the name of the slot
  • token: if a token is present in this slot, a Token object. If no token is present in the slot, this property is null.

Token objects have the following properties:

name
string. Name of the token.
manufacturer
string. Name of the token's manufacturer.
HWVersion
string. Hardware version, as a PKCS #11 version number (two 32-bit integers separated with a dot, like "1.0".
FWVersion
string. Firmware version, as a PKCS #11 version number (two 32-bit integers separated with a dot, like "1.0".
serial
string. Serial number, whose format is defined by the token specification.
isLoggedIn
boolean: true if the token is logged on already, false otherwise.

If the module could not be found or some other error occurs, the promise will be rejected with an error message.

Browser compatibility

BCD tables only load in the browser

Examples

Installs a module, then lists its slots and list the tokens they contain:

function onInstalled() {
  return browser.pkcs11.getModuleSlots("my_module");
}

function onGotSlots(slots) {
  for (slot of slots) {
    console.log(`Slot: ${slot.name}`);
    if (slot.token) {
      console.log(`Contains token: ${slot.token.name}`);
    } else {
      console.log('Is empty');
    }
  }
}

browser.pkcs11.installModule("my_module")
.then(onInstalled)
.then(onGotSlots);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:48 次

字数:3683

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文