Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: SubtleCrypto importKey returning invalid CryptoKey #3737

Closed
pcbzzz opened this issue Aug 11, 2023 · 0 comments
Closed

🐛 BUG: SubtleCrypto importKey returning invalid CryptoKey #3737

pcbzzz opened this issue Aug 11, 2023 · 0 comments
Labels
bug Something that isn't working

Comments

@pcbzzz
Copy link

pcbzzz commented Aug 11, 2023

Which Cloudflare product(s) does this pertain to?

Workers Runtime

What version(s) of the tool(s) are you using?

wrangler@^3.1.2

What version of Node are you using?

No response

What operating system are you using?

macOS

Describe the Bug

I'm trying to import a public key using importKey, but it just returns an empty CryptoKey, meanwhile in NodeJS it'll import just fine.

Code:

const publicKey = await crypto.subtle.importKey(
  "spki",
  Buffer.from(
    "3059301306072a8648ce3d020106082a8648ce3d03010703420004ea1371a3dca5e8a934bf5e434ead0aeee951cc1d09774df2f1aa6948dde7c67cb4bc62502d1d05e03e7ae318820875ff988093e14cc541660366b5af868267c4",
    "hex"
  ),
  { name: "ECDSA", namedCurve: "P-256", hash: { name: "SHA-256" } },
  true,
  ["verify"]
);

On the worker runtime it returns

CryptoKey {
  usages: undefined,
  algorithm: undefined,
  extractable: undefined,
  type: undefined
}

In NodeJS it returns

CryptoKey {
  type: 'public',
  extractable: true,
  algorithm: { name: 'ECDSA', namedCurve: 'P-256' },
  usages: [ 'verify' ]
}

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@pcbzzz pcbzzz added the bug Something that isn't working label Aug 11, 2023
@pcbzzz pcbzzz closed this as completed Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
Development

No branches or pull requests

1 participant