Can't change algorithm
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript, node.js
Research direction
Run the supplied jwt.sign reproduction first, then trace the call through node_modules/jsonwebtoken/sign.js, node_modules/jws/lib/sign-stream.js, and node_modules/jwa/index.js. Compare the ES256 and README RS256 cases, including the supplied key values. Done means identifying whether the failure is in algorithm handling or PEM input and documenting or fixing the reproducible cause.
Written by the indexing model from the issue text.
Description
Description
Trying to use ES256 by passing algorithm: 'ES256' into options and getting:
Error: error:0908F066:PEM routines:get_header_and_data:bad end line
at Sign.sign (node:internal/crypto/sig:131:29)
at sign (/Users/liamdoyle/Developer/limegorilla/apple-jwt-node-test/node_modules/jwa/index.js:152:45)
at Object.sign (/Users/liamdoyle/Developer/limegorilla/apple-jwt-node-test/node_modules/jwa/index.js:200:27)
at Object.jwsSign [as sign] (/Users/liamdoyle/Developer/limegorilla/apple-jwt-node-test/node_modules/jws/lib/sign-stream.js:32:24)
at Object.module.exports [as sign] (/Users/liamdoyle/Developer/limegorilla/apple-jwt-node-test/node_modules/jsonwebtoken/sign.js:204:16)
at file:///Users/liamdoyle/Developer/limegorilla/apple-jwt-node-test/app.js:22:26
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
at async loadESM (node:internal/process/esm_loader:88:5) {
library: 'PEM routines',
function: 'get_header_and_data',
reason: 'bad end line',
code: 'ERR_OSSL_PEM_BAD_END_LINE'
Reproduction
let generatedToken = jwt.sign({
iss: teamId, // Required by Apple
exp: Math.floor(Date.now() / 1000) + (60 * 60),
}, token, {
algorithm: 'ES256',
header: {
kid: keyId
}
});
Also tried using this example from the readme:
jwt.sign({ foo: 'bar' }, privateKey, { algorithm: 'RS256' });
Same error.
Environment
Node 16.3
jsonwebtoken 8.5.1
macOS 12
- Dominant language
- JavaScript
- Stars
- 18.2k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from auth0/node-jsonwebtoken
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
auth0/node-jsonwebtoken#1042 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
auth0/node-jsonwebtoken#1000 · 2 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 65/100
auth0/node-jsonwebtoken#1046 ·
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
auth0/node-jsonwebtoken#1034 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
auth0/node-jsonwebtoken#1032 ·
All issues in auth0/node-jsonwebtoken
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
antfu-collective/icones#398 ·
-
ECmail.com Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
wesbos/burner-email-providers#554 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
components-web-app/docs#92 ·