简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM