Error: error:0909006C:PEM routines:get_name:no start line

我怕爱的太早我们不能终老 提交于 2021-01-24 17:46:16

问题


I am trying to verify a jwt using jsonwebtoken. When I am using:

jwt.verify(jwt, publicKey)

I am getting a :

JsonWebTokenError {name: "JsonWebTokenError", message: "invalid algorithm", stack: "JsonWebTokenError: invalid algorithm }

When I am using:

jwt.verify(jwt, publicKey, { algorithms: 'RS256'}) 

I am getting:

Error: error:0909006C:PEM routines:get_name:no start line

Any ideas? Is there an alternative to verify a jwt?

Update

The problem lies on the RS256 selection probably.


回答1:


Try passing an options object with both audience and issuer attributes .

let options = {
    clockTolerance: 60*24*10, 
    audience: "account",
    issuer: "https://login.someorganization/auth"
};

jwt.verify(jwt, publicKey, options);



回答2:


From the sample above, you are referencing the jwt instance in your verify function

Use the link npm-jsonwebtoken

You will have to verify a token, not the jwt instance Example

const jwt = require('jsonwebtoken')

var decoded = jwt.verify(token, 'private_key');

Where 'private_key' is the exact key used for hashing



来源:https://stackoverflow.com/questions/62173970/error-error0909006cpem-routinesget-nameno-start-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!