I have JsonWebKeys(JWK) for id_token and access_token. Then I got my id_token, from /token url. How to validate this JWT id_token using JWK in C#.
Needless to say I have tried almost everything but(IdenityModels.Jwt, etc) but JwtSecurityTokenHandler does not take JsonWebKey. I am using RS512 as signing algorithm.
I just implemented this myself for Google IdToken validation as:
Where
keyProvider
is a:RSA
etc. is justSystem.Security.Cryptography
, whileBase64UrlEncoder
is fromSystem.IdentityModel
(but easy enough to do yourself)Unfortunately, it doesn't look like the other
kty
/alg
values are as easy to support, e.g. there's noECDsa.ImportParameters()
, it wants a genericCngKey
frombyte[]
, so someone doing a generic .NET JWK library would have to pack thex
,y
params themselves, presumably.