public void FetchJWKKeyAsRSATokenVerificationKey() { string keysResponse = @"{ ""keys"": [ { ""kty"": ""RSA"", ""alg"": ""RS256"", ""use"": ""sig"", ""kid"": ""d83ad1bbaac388a4dcb4957e53282a0e7d0bf98a"", ""n"": ""temCVy5oxWCEUwHUqGXxvHnySlaZtT_JmHm0zICxsanboYss-b3nOqIXN45L5TyTiNbOBgE6vge2TfIjo_NqXBiKjRNl_g7F4iwl07p2abn3KQ6mgYDlFMhJJOXG4-0dMORBgi3hQi8VajLHJ04FoorZsf__FDb1gvvnPObUQwM="", ""e"": ""AQAB"" } ] }"; JsonWebKey jsonWebKey = FetchAndValidateJsonWebKeyWithCommonProperties(keysResponse); Assert.AreEqual(0, jsonWebKey.X5c.Count, "x5c should not contain elements "); Assert.IsNull(jsonWebKey.X5t, "x5t field should be null"); RsaTokenVerificationKey tokenVerificationKey = jsonWebKey.AsTokenVerificationKey() as RsaTokenVerificationKey; Assert.IsNotNull(tokenVerificationKey); RSAParameters parameters = tokenVerificationKey.GetRsaParameters(); Assert.IsNotNull(parameters); Assert.IsNotNull(parameters.Modulus); Assert.IsNotNull(parameters.Exponent); }
public void FetchJWKKeyAsX509TokenVerificationKey() { string keysResponse = @" { ""keys"": [ { ""kty"":""RSA"", ""use"":""sig"", ""kid"":""kriMPdmBvx68skT8-mPAB3BseeA"", ""x5t"":""kriMPdmBvx68skT8-mPAB3BseeA"", ""n"":""kSCWg6q9iYxvJE2NIhSyOiKvqoWCO2GFipgH0sTSAs5FalHQosk9ZNTztX0ywS/AHsBeQPqYygfYVJL6/EgzVuwRk5txr9e3n1uml94fLyq/AXbwo9yAduf4dCHTP8CWR1dnDR+Qnz/4PYlWVEuuHHONOw/blbfdMjhY+C/BYM2E3pRxbohBb3x//CfueV7ddz2LYiH3wjz0QS/7kjPiNCsXcNyKQEOTkbHFi3mu0u13SQwNddhcynd/GTgWN8A+6SN1r4hzpjFKFLbZnBt77ACSiYx+IHK4Mp+NaVEi5wQtSsjQtI++XsokxRDq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EO5t4Cw+zZg70dJ/hH/ODYRMorfXEW+8uKmXMKmX2wyxMKvfiPbTy5LmAU8Jvjs2tLg4rOBcXWLAIarZ""] } ] }"; JsonWebKey jsonWebKey = FetchAndValidateJsonWebKeyWithCommonProperties(keysResponse); X509CertTokenVerificationKey tokenVerificationKey = jsonWebKey.AsTokenVerificationKey() as X509CertTokenVerificationKey; Assert.IsNotNull(tokenVerificationKey); Assert.IsNotNull(jsonWebKey.X5c); Assert.IsNotNull(jsonWebKey.X5t); X509Certificate2 cert = tokenVerificationKey.X509Certificate2; Assert.IsNotNull(cert); }