Migrate from v2 to v4 #556
Unanswered
MahamoudTBS
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Im attempting to convert the following code from v2 to v4.
Due to the breaking changes after v2, I'm unsure how to convert
asKey
andKeystore
to equivalent methods in v4.An attempt at converting
asKey
toimportPKCS8
resulted in the following error message:"pkcs8" must be PKCS#8 formatted string
Below is a snippet of my v2 code:
const { JWK: { asKey }, JWKS: { KeyStore } } = require('jose')
let keyStore = new KeyStore();
const keyObj = {
key: fs.readFileSync(akeyPath, 'utf8'),
// -----BEGIN ENCRYPTED PRIVATE KEY-----passphrase: secretKey
}
const options = {
"kid": "******************_sig_es256",
"use": "sig",
"alg": "ES256"
}
const key = asKey(keyObj, options)
keyStore.add(key)
return ks.toJWKS(true)
Beta Was this translation helpful? Give feedback.
All reactions