Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

WebCrypto reports unsupported JWK key type when exporting a key #39805

Copy link
Copy link

Description

@SakerGT
Issue body actions

Version

v16.7.0

Platform

Linux cloud 5.4.0-81-generic #91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

WebCrypto

What steps will reproduce the bug?

This is a bit long winded, but here is what causes the issue for me.

  1. Create a RSA-PSS certificate (e.g. using OpenSSL), 4096 bit in file pss-cert.pem (private key in separate file).
  2. Read the certificate file and import the public key:
const cert = new X509Certificate(fs.readFileSync("pss-cert.pem"));
const publicKey = await subtle.importKey('node.keyObject', 
                            cert.publicKey, 
                            { hash: 'SHA-512', name: 'RSA-PSS'},
                            true,
                            ['verify']);
  1. export the JWK
const jwk = await subtle.exportKey('jwk', publicKey);

Results in:

Error: Unsupported JWK Key Type.
    at exportKeyJWK (node:internal/crypto/webcrypto:325:40)
    at SubtleCrypto.exportKey (node:internal/crypto/webcrypto:394:24)
    at start (/usr/src/app/webcrypto.js:73:21) {
  code: 'ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE'
}

Works in v16.5.0 and earlier

How often does it reproduce? Is there a required condition?

Always reproducible

What is the expected behavior?

Should export a JWK with kty: 'RSA'

What do you see instead?

Error: Unsupported JWK Key Type.
    at exportKeyJWK (node:internal/crypto/webcrypto:325:40)
    at SubtleCrypto.exportKey (node:internal/crypto/webcrypto:394:24)
    at start (/usr/src/app/webcrypto.js:73:21) {
  code: 'ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE'
}

Additional information

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.webcrypto

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.