pee cee beez
pee cee beez
CDCloudflare Developers
Created by pee cee beez on 8/11/2023 in #workers-help
SubtleCrypto providing invalid CryptoKey
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"]
);
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
}
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' ]
}
CryptoKey {
type: 'public',
extractable: true,
algorithm: { name: 'ECDSA', namedCurve: 'P-256' },
usages: [ 'verify' ]
}
6 replies
CDCloudflare Developers
Created by pee cee beez on 8/10/2023 in #workers-help
Using X509Certificate
Is there any way to parse and verify certificates in workers? It seems like it's unsupported in node_compat, but my only other solution is to host a NodeJS server, only for parsing certificate signed JWT tokens.
8 replies