Repository navigation
Error: PEM_read_bio_PUBKEY after upgrade to Node 10.10 #22815
Description
Activity
@nodejs/crypto
- addedcryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.
on Sep 12, 2018 This points to #22553, I'll investigate later.
@YangYu000 Would it be possible to upload
public.pem? Actually, any public key that fails would be enough, it is important to include data surrounding the PEM key though, e.g. whitespace.I cannot reproduce this using Node.js 10.9.0 vs 10.10.0 using the code
const assert = require('assert'); const fs = require('fs'); const jwt = require('jsonwebtoken'); const privateKey = fs.readFileSync('./private.pem'); const publicKey = fs.readFileSync('./public.pem'); const token = jwt.sign('Hello world!', privateKey, { algorithm: 'RS256' }); console.log(token); const payload = jwt.verify(token, publicKey); console.log(payload);
Valid keys don't produce any errors and any invalid keys I tried produce errors in both versions. It would be helpful to have an example with a key pair that works in previous versions.
@tniessen sorry, the pem file in code is confidential and currently using widely in my company business, so I can't show it in public.
But I may generate another for test usage, please wait me for one or two days, thanks.@YangYu000 That would be great! As long as the error message pops up, any key pair would be enough.
Ping @YangYu000.
@tniessen Sorry for the delay.
Here's a pem file content ok with node 10.9 and before but fail in 10.10Bag Attributes localKeyID: 21 54 3F 46 7D 44 84 94 F8 7C EE F2 9D 6D 33 1D 27 3E 97 C2 subject=/C=CN/ST=Shanghai/L=Shanghai/O=FungoTec/OU=Tech/CN=Name/emailAddress=edyuy@zmyseries.com issuer=/C=CN/ST=Shanghai/L=Shanghai/O=FungoTec/OU=Tech/CN=Name/emailAddress=edyuy@zmyseries.com -----BEGIN CERTIFICATE----- MIID6DCCAtCgAwIBAgIJAMguk3GtYYASMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYD VQQGEwJDTjERMA8GA1UECAwIU2hhbmdoYWkxETAPBgNVBAcMCFNoYW5naGFpMREw DwYDVQQKDAhGdW5nb1RlYzENMAsGA1UECwwEVGVjaDENMAsGA1UEAwwETmFtZTEi MCAGCSqGSIb3DQEJARYTZWR5dXlAem15c2VyaWVzLmNvbTAeFw0xODA5Mj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Uh+sV45k44no3yiTmGrM= -----END CERTIFICATE------ addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Sep 29, 2018 - added a commit that references this issue
on Sep 29, 2018 - added a commit that references this issue
on Jul 27, 2026
My code is like
and runs without problem with Node 8 and Node 10.8/10.9 (Ubuntu and Debian, NodeJS offical APT source)
After I upgrade to Node 10.10 yesterday, on
JWT.verifythrows