.net core 从JSON创建JsonWebKey

.net core 从JSON创建JsonWebKey,.net-core,jwt,json-web-signature,.net Core,Jwt,Json Web Signature,我有一个包含jwks值的url。看起来像这样 { "keys": [ { "kty": "RSA", "e": "AQAB", "use": "sig", "kid": "Has a Real Value Here", "alg": "RS256", "n": "Has a Real Value here" }] } 我尝试将该json输入JsonWebKey构造函数,如下所示: HttpCli

我有一个包含jwks值的url。看起来像这样

{
  "keys": [
   {
       "kty": "RSA",
       "e": "AQAB",
       "use": "sig",
       "kid": "Has a Real Value Here",
       "alg": "RS256",
       "n": "Has a Real Value here"
   }]
}
我尝试将该json输入JsonWebKey构造函数,如下所示:

HttpClient client = new HttpClient();
var response = client.GetAsync("https://myIdp/oauth2/jwks").Result;
var jwksString = response.Content.ReadAsStringAsync().Result;

publicJwk = new JsonWebKey(jwksString);
HttpClient client = new HttpClient();
var response = client.GetAsync("https://myIdp/oauth2/jwks").Result;
var jwksString = response.Content.ReadAsStringAsync().Result;

jwkset = new JsonWebKeySet(jwksString);
当我这样做时,类中的任何值都不会被填充。获取值的对象是一个AdditionalData字段。这一切都取决于放在那里的json


有没有办法让JsonWebKey构造函数实际解析出Json?

jwks值是数组,因此需要创建jsonwebkeyset,它是JsonWebKey的集合。 大概是这样的:

HttpClient client = new HttpClient();
var response = client.GetAsync("https://myIdp/oauth2/jwks").Result;
var jwksString = response.Content.ReadAsStringAsync().Result;

publicJwk = new JsonWebKey(jwksString);
HttpClient client = new HttpClient();
var response = client.GetAsync("https://myIdp/oauth2/jwks").Result;
var jwksString = response.Content.ReadAsStringAsync().Result;

jwkset = new JsonWebKeySet(jwksString);