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

crypto.subtle.importKey with verify raises "Invalid key usages" #24141

Closed
TheCarpetMerchant opened this issue Jun 7, 2024 · 2 comments
Closed
Labels
needs info needs further information to be properly triaged

Comments

@TheCarpetMerchant
Copy link

deno 1.44.1 (release, x86_64-pc-windows-msvc)
v8 12.6.228.3
typescript 5.4.5

Calling this results in an error "Invalid key usages"
crypto.subtle.importKey('pkcs8', buffer, {name: "RSASSA-PKCS1-v1_5", hash: "SHA-256"}, true, ["verify"]);

Looking at

const SUPPORTED_KEY_USAGES = {
it seems we need to provide "sign". But "verify" is marked in the docs as a valid value.

@lucacasonato
Copy link
Member

Are you trying to import a private key instead of a public key?

@lucacasonato lucacasonato added the needs info needs further information to be properly triaged label Jun 8, 2024
@lucacasonato
Copy link
Member

No response from OP, so closing. For future readers: if you are seeing this error: you are trying to import a private key in an API that can only import public keys, or a public key in an API that can only import private keys. Specifically, "sign" can only be used with a private key, and "verify" can only be used with a public key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info needs further information to be properly triaged
Projects
None yet
Development

No branches or pull requests

2 participants