Node-jsonwebtoken: error in jwt.verify

Created on 26 Apr 2015  路  3Comments  路  Source: auth0/node-jsonwebtoken

Hi there,

I'm working with jwt.verify and I'm getting an "invalid algorithm" error.

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

_Note: I tried switching up my PEM encoding from PKCS8 to traditional OpenSSL, but then I get an "invalid signature" error instead, which leads me to believe that PKCS8 is required._

Here is my code:

var jwt = require('jsonwebtoken');
var payload = {foo: 'bar'};
var rsa_token = jwt.sign(payload, private_pem, {algorithms: 'RS256'});
jwt.verify(rsa_token, public_pem);

Is RS256 properly supported?

Also please note that I'm testing this in the browser with browserify.

Any guidance on this would be much appreciated. Thanks!

Most helpful comment

You are doing it wrong, on the sign part. It is algorithmsingular

Please check the documentation.

All 3 comments

You are doing it wrong, on the sign part. It is algorithmsingular

Please check the documentation.

OK thank you. It now works for RSA PEMs with PKCS8 encoding, but I still get "invalid signature" when I use traditional OpenSSL encoding.

@shea256 please open another issue with an example and I will have a look

Was this page helpful?
0 / 5 - 0 ratings