I'm following this article to implement Azure B2C in our Node.JS app. I got back JWT token and trying to validate signature. Using jsonwebtoken npm module to verify my token. Also, I got public keys from the OpenID Connect metadata endpoint. They are in JSON and looks like this:
{ "keys": [{
"kid": "some kid value",
"nbf": some number,
"use": "sig",
"kty": "RSA",
"e": "AQAB",
"n": "some long key"
}, {
"kid": "some kid value",
"nbf": some number,
"use": "sig",
"kty": "RSA",
"e": "AQAB",
"n": "some long key"
}, {
"kid": "some kid value",
"nbf": some number,
"use": "sig",
"kty": "RSA",
"e": "AQAB",
"n": "some long key"
}]
}
So when I'm trying to pass 'n' value from appropriate key to the
jwt.verify(token, 'my n value go here', { algorithms: ['RS256'] }, callbackFunction());
I got
Error: PEM_read_bio_PUBKEY failed
I feel like I'm passing the wrong key, and I could not find any explanation about how I can use this public key metadata to validate tokens. The only helpful line from the article:
A description of how to perform signature validation is outside the scope of this document. Many open source libraries are available to help you with this if you need it.
How do I validate a signature?
x5c
which looks more like a key. – juunas