JWT signing with private key & passphrase throws error
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, node.js
- Lĩnh vực
- authentication, security
Hướng nghiên cứu
Tái hiện ví dụ bằng Node.js v12.20.0, sau đó lần theo đường dẫn ký qua jsonwebtoken/sign.js, jwa/index.js và jws/lib/sign-stream.js được hiển thị trong stack trace. Bản sửa được hoàn tất khi một khóa riêng PEM được bảo vệ bằng passphrase có thể ký token PS512 mà không gặp lỗi kiểu key.key, kèm theo kiểm thử hồi quy cho trường hợp này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- JavaScript
- Star
- 18.2k
- Fork
- 1.3k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của auth0/node-jsonwebtoken
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
auth0/node-jsonwebtoken#1042 · 1 bình luận ·
-
`jwt.sign()` callback is executed twice for "The payload already has an "..." property" errors Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
auth0/node-jsonwebtoken#1000 · 2 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 65/100
auth0/node-jsonwebtoken#1046 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
auth0/node-jsonwebtoken#1034 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
auth0/node-jsonwebtoken#1032 ·
Tất cả issue của auth0/node-jsonwebtoken
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
area-deployment area-integrations triage:bot-seen
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 86/100
-
Issue-Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
sugarlabs/musicblocks#8924 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
ArduPilot/ardupilot_wiki#8088 ·
-
[BUG] createTool tools cannot be registered with Mastra when exactOptionalPropertyTypes is enabled Đang mởcustomer-eng status: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100