Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you verify a JWT token with a x.509 certificate in node?

I'm trying to make a node script verify a JWT token. I have the public key (it's a x.509 certificate) and the JWT.

I tried using https://github.com/auth0/node-jsonwebtoken but unfortunately it seems that they don't support x.509.

If you know of a package that verifies JWT tokens with x.509 certs I would appreciate it.

Thanks!

like image 559
Y. Brahimi Avatar asked Mar 01 '16 17:03

Y. Brahimi


1 Answers

JWT can be signed with public/private keys. The method you are looking for is this one: https://github.com/auth0/node-jsonwebtoken#jwtverifytoken-secretorpublickey-options-callback

This tests show examples of how to use it:

https://github.com/auth0/node-jsonwebtoken/blob/master/test/jwt.rs.tests.js

You can also use http://jwt.io

like image 146
Eugenio Pace Avatar answered Sep 24 '22 01:09

Eugenio Pace