Hi, i’m trying to verify a jwt using a jwks and reading the documentation i’ve found that the verify policy can automatically lookup for the matching kid in the jwks and choose that key. The policy is able to choose the correct jwk but it always fail when try to parse the key. The error description is this:
{"fault":{"faultstring":"Failed to parse key: policy(VerifyJWT)","detail":{"errorcode":"steps.jwt.KeyParsingFailed"}}}
I’m using a service callout to retrive the jwks and my verify jwt policy look like this:
That JWK is not in the correct JWKS format. The error message you saw, (Failed to parse key: policy(VerifyJWT)), indicates that Apigee cannot parse the JWK. And that would be expected.
It seems like you contrived that JWKS. The n string should not have a “BEGIN PUBLIC KEY” in it.
Your IDP, the thing that issues the token, will have a JWKS endpoint if it supports OpenID Connect. You need to find it and USE THAT. The content available at that JWKS endpoint will have a valid format.
If you do not have an IDP, then you can try using this example JWKS and token-generator service. https://jwks-service.appspot.com/. This should be used only for testing.
To use that test service, you can
configure your VerifyJWT policy to reference the JWKS URI, like this
<VerifyJWT name='VJWT-1'>
<Algorithm>RS256</Algorithm>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<PublicKey>
<JWKS uri='https://jwks-service.appspot.com/.well-known/jwks.json'/>
</PublicKey>
<!-- other elements here as desired -->
</VerifyJWT>
use the web app to generate a signed JWT using an RSA key with RS256
copy/paste that generated JWT, and then pass it in via an http request, to a proxy that contains the verifyJWT policy.