JWT signing with private key & passphrase throws error
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
- Ambito
- authentication, security
Direzione di ricerca
Riproduci l’esempio con Node.js v12.20.0, quindi traccia il percorso di firma attraverso jsonwebtoken/sign.js, jwa/index.js e jws/lib/sign-stream.js mostrati nello stack trace. La correzione è completa quando una chiave privata PEM protetta da passphrase può firmare un token PS512 senza l’errore di tipo key.key, con una copertura di regressione per questo caso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
Signing jwt token with private key & passphrase results in error. Generated private key as below
ssh-keygen -t rsa -b 2048 -m PEM -f PS512.key and add passphrase
Reproduction
const jwt = require('jsonwebtoken');
const privateKey = `<copy & paste the generated private key here>`;
const token = jwt.sign(
{ test: 12 },
{ key: privateKey , passphrase: '...' }, {
algorithm: 'PS512'
});
console.log(token);
Error
internal/crypto/keys.js:288
throw new ERR_INVALID_ARG_TYPE(
^
TypeError [ERR_INVALID_ARG_TYPE]: The "key.key" property must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received an instance of Object
at prepareAsymmetricKey (internal/crypto/keys.js:288:13)
at preparePrivateKey (internal/crypto/keys.js:308:10)
at Sign.sign (internal/crypto/sig.js:94:46)
at Object.sign (jwt-playground/node_modules/jwa/index.js:174:45)
at Object.jwsSign [as sign] (jwt-playground/node_modules/jws/lib/sign-stream.js:32:24)
at Object.module.exports [as sign] (jwt-playground/node_modules/jsonwebtoken/sign.js:204:16)
at Object.<anonymous> (jwt-playground/pem-format-passphrase/jwt-pem-formar-passphrase.js:75:19)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32) {
code: 'ERR_INVALID_ARG_TYPE'
}
Environment
- Version of the library used: 8.5.1
- Version of the Node.js: v12.20.0
- OS: macOS Monterey - 12.6
- Lingua principale
- JavaScript
- Stelle
- 18.2k
- Fork
- 1.3k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di auth0/node-jsonwebtoken
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
auth0/node-jsonwebtoken#1042 · 1 commento ·
-
`jwt.sign()` callback is executed twice for "The payload already has an "..." property" errors Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
auth0/node-jsonwebtoken#1000 · 2 commenti · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 65/100
auth0/node-jsonwebtoken#1046 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
auth0/node-jsonwebtoken#1034 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
auth0/node-jsonwebtoken#1032 ·
Tutte le issue di auth0/node-jsonwebtoken
Issue simili
-
Update HugeIcons library Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
antfu-collective/icones#398 ·
-
ECmail.com Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
wesbos/burner-email-providers#554 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
components-web-app/docs#92 ·