Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Error: secretOrPrivateKey must be an asymmetric key when using ES256

オープン
#898 コメント 13 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript, node.js, typescript

調査の方向性

issuer.getPrivateKey() の値と、示されている ES256 オプションを使用して、src/app.ts:151 の呼び出しを再現します。node_modules/jsonwebtoken/sign.js:124 まで失敗を追跡し、その後、sign が受け付けるキー値と verify に渡される値を比較します。サポートされる動作または必要なキー形式が確立され、焦点を絞った回帰テストまたはドキュメントでカバーされれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Description

I am unable to sign a jwt by using the private key associated to a Metamask wallet. Ideally I would like to sign a jwt for a verifiable credential by using the private key of the issuer of the credential:

const vcPayload = {
  sub: sub.getDid(),
  nbf: Math.floor(Date.now() / 1000),
  vc: {
    '@context': ['https://www.w3.org/2018/credentials/v1'],
    type: ['VerifiableCredential'],
    credentialSubject: {
      degree: {
        type: 'BachelorDegree',
        name: 'Baccalauréat en musiques numériques'
      }
    }
  }
}

const vcJwt = jwt.sign(vcPayload, issuer.getPrivateKey(), { algorithm: 'ES256' });

const decodedJwt = jwt.decode(vcJwt, { complete: true });
console.log(`Decoded VC: ${JSON.stringify(decodedJwt)}`);

const verifiedJwt = jwt.verify(vcJwt, issuer.getPublicKey(), { algorithms: ['ES256'] });
console.log(`Verified VC: ${JSON.stringify(JSON.stringify(verifiedJwt))}`);

The problem I am encountering is the following one:

Error: secretOrPrivateKey must be an asymmetric key when using ES256
    at module.exports [as sign] (node_modules/jsonwebtoken/sign.js:124:22)
    at main (src/app.ts:151:21)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {stack: 'Error: secretOrPrivateKey must be an asymmetr…ions (node:internal/process/task_queues:95:5)', message: 'secretOrPrivateKey must be an asymmetric key when using ES256'}
Environment

"jsonwebtoken": "9.0.0"

主要言語
JavaScript
スター
18.2k
フォーク
1.3k
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

auth0/node-jsonwebtoken のほかの issue

auth0/node-jsonwebtoken の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。