0

I try to verify a JWT signature in an apex class.
It is a RS SHA 256 token.
It is an id token received from Auth0.

    Blob bPublicKey = EncodingUtil.base64Decode(publicKey);

    Blob bsignature = EncodingUtil.base64Decode(signature
                .replace('-', '+')
                .replace('_', '/')
                .rightPad(math.mod(signature.length() + (math.mod(4 - signature.length(), 4)), 4))
                .replace(' ','='));

    System.debug(Crypto.verify('RSA-SHA256', Blob.valueOf(payload), bsignature, bPublicKey));

Payload is the payload section of the JWT.
Signature is the signature section of the JWT.
I used the x5c field of my jwks key file as the publicKey.
I receive this error.

System.SecurityException: Invalid Crypto Key

I think that I need to make some work on the x5c to extract the real public key from it. How do I do that?
Also if there are issues with my encoding if you can let me know.

4

0

You must log in to answer this question.

Browse other questions tagged .