Skip to content

Why does getting certificate tries to create an object? #89

@ayZagen

Description

@ayZagen

Hello,

With following example:

import { Crypto, type CryptoKey } from 'node-webcrypto-p11'

const config = {
  library: '...',
  name: '...',
  slot: 0,
  readWrite: true,
  pin: '...'
}

const crypto = new Crypto(config);

(async () => {
  const certs = await crypto.certStorage.keys()
  console.log(certs)
  for (const cert of certs) {
    const detail = await crypto.certStorage.getItem(cert)
    console.log(detail)
  }
})()

I get following error:

Error: CKR_ATTRIBUTE_VALUE_INVALID:19
    at PKCS11.C_CreateObject (\libs\pkcs11js\index.js:286:18)
    at Session.create (\node_modules\graphene-pk11\build\cjs\session.js:53:34)
    at RsaCrypto.importJwkPublicKey (\node_modules\node-webcrypto-p11\build\index.js:2083:47)
    at RsaCrypto.importKey (\node_modules\node-webcrypto-p11\build\index.js:1942:29)
    at RsaSsaProvider.onImportKey (\node_modules\node-webcrypto-p11\build\index.js:2592:39)
    at RsaSsaProvider.importKey (\node_modules\node-webcrypto-p11\node_modules\webcrypto-core\build\webcrypto-core.js:232:33)
    at SubtleCrypto.importKey (\node_modules\node-webcrypto-p11\node_modules\webcrypto-core\build\webcrypto-core.js:1532:25)
    at SubtleCrypto.importKey (\node_modules\node-webcrypto-p11\build\index.js:2969:33)
    at PublicKey.export (\node_modules\@peculiar\x509\build\x509.cjs.js:1315:30)
    at X509Certificate.exportKey (\node_modules\node-webcrypto-p11\build\index.js:491:75)

Looking to stacktrace, it seems the library trying to create something on the SmartCard. Is this really necessary?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions