Microsoft.IdentityModel.Tokens.SecurityTokenDecryptionFailedException : 'IDX10609: расшифровка не удалась. Ключи не пробовались: токен: 'System.String'.'
При использовании
Код: Выделить всё
var handler = new JwtSecurityTokenHandler();
handler.ValidateToken(
idToken,
validationParameters,
out SecurityToken validatedToken
);
Код: Выделить всё
var idToken = Convert.ToString(tokenDictionary["id_token"]);
var decryptionKey = @"-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----";
WebProxy webProxy = new WebProxy("http://proxy", false);
var httpHandler = new System.Net.Http.HttpClientHandler
{
Proxy = webProxy,
UseProxy = true
};
var httpClient = new System.Net.Http.HttpClient(httpHandler);
var documentRetriever = new HttpDocumentRetriever(httpClient)
{
RequireHttps = true
};
var configurationManager =
new ConfigurationManager(
"https://auth.integ01.dev-franceconnect.fr/api/v2/.well-known/openid-configuration",
new OpenIdConnectConfigurationRetriever(),
documentRetriever // ajout du proxy
);
OpenIdConnectConfiguration config =
configurationManager.GetConfigurationAsync(CancellationToken.None).Result;
var key = new SymmetricSecurityKey(Encoding.Unicode.GetBytes(decryptionKey));
var validationParameters = new TokenValidationParameters
{
ValidIssuer = "https://auth.integ01.dev-franceconnect.fr/api/v2",
ValidAudience = "client_id",
IssuerSigningKeys = config.SigningKeys,
TokenDecryptionKeys = new[] { key },
ValidateIssuer = true,
ValidateAudience = true,
ValidateIssuerSigningKey = true,
ValidateLifetime = true
};
// fails here
handler.ValidateToken(
idToken,
validationParameters,
out SecurityToken validatedToken
);
Подробнее здесь: https://stackoverflow.com/questions/798 ... atetoken-w
Мобильная версия