Skip to content

jwt::InvalidKeyError #99

@clobotorre

Description

@clobotorre

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions