Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Can't change algorithm

未关闭
#803 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
领域
backend, security

调研方向

先运行提供的 jwt.sign 复现代码,然后通过 node_modules/jsonwebtoken/sign.js、node_modules/jws/lib/sign-stream.js 和 node_modules/jwa/index.js 跟踪调用。比较 ES256 和 README RS256 两种情况,包括提供的密钥值。完成标准是确定失败发生在算法处理还是 PEM 输入,并记录或修复可复现的原因。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
JavaScript
星标
18.2k
派生
1.3k
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

auth0/node-jsonwebtoken 的其他 Issue

查看 auth0/node-jsonwebtoken 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。