-
Notifications
You must be signed in to change notification settings - Fork 121
Description
I have this minimal jwt verification example that throws a jwt::InvalidKeyError exception:
#include "jwt/jwt.hpp"
int main() {
std::string token = "(omitted)";
std::string secret = "-----BEGIN PUBLIC KEY-----\nMIID"(omitted)"\n-----END PUBLIC KEY-----";
auto dec_obj = jwt::decode(token, jwt::params::algorithms({"RS256"}), jwt::params::secret(secret), jwt::params::verify(true));
return 0;
}
The token was obtained from an openId issuer on an user authentication flow. From the token header I got the alg and the kid attributes.
Using the issuer jwks_uri and the kid from the token header I got the x5c string:
{
"kty": "RSA",
"use": "sig",
"kid": "(omitted)",
"x5t": "(omitted)",
"n": "(omitted)",
"e": "(omitted)"
"x5c": ["MIID(omitted)"],
"issuer": "(omitted)",
}
As stated on #51, I added to the x5c string a '\n' after each block of 64 characters, and finally enclosed it between "-----BEGIN PUBLIC KEY-----\n and -----END PUBLIC KEY-----
What was wrong here?
What should I do to verify the token with this library using the 'n' and 'e' attributes instead the kid?