I am trying to integrate Identityserver 4 with a Azure Active directory, but receive following error:
Microsoft.IdentityModel.Tokens.SecurityTokenSignatureKeyNotFoundException: IDX10501: Signature validation failed. Unable to match 'kid': 'RrQqu9rydBVRWmcocuXUb20HGRM', token: '{"alg":"RS256","typ":"JWT","x5t":"RrQqu9rydBVRWmcocuXUb20HGRM","kid":"RrQqu9rydBVRWmcocuXUb20HGRM"}.{"aud":"###########,"iss":"###########","iat":1479457186,"nbf":1479457186,"exp":1479461 086,"amr":["pwd"],"c_hash":"ZpWv18fS5_fPTxZgHITCrw","family_name":"Smith","given_name":"Bob","ipaddr":"127.0.0.1","name":"Bob Smith","nonce":"6361505428d5473221d.WYzMzZiMTUtZmNkMS00NjcwLTljMDktZDRlZTk2ZDk1ZjJlYzU0NTBkOTgtYTAzqkifdzQyLW88Dktw0YzAzNmE0M TRj","oid":"###########,"onprem_sid":"###########","platf":"3","sub":"###########","tid":"88cb0952-ee76-4b6e-a6c4-f7da82b4c15a","unique_name":"[email protected]","upn":"[email protected]","ver":"1.0"}'. at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(String token, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken) at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.ValidateToken(String idToken, AuthenticationProperties properties, TokenValidationParameters validationParameters, JwtSecurityToken& jwt) at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.<HandleRemoteAuthenticateAsync>d__19.MoveNext()
I've tried most suggestions which were on the internet but I am getting desperate on solutions. Here is my configuration of the OIDC middleware so far:
`
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme, //same as "external"
SignOutScheme = IdentityServerConstants.SignoutScheme, //same as "idsrv"
DisplayName = "Azure AD",
ClientId = Configuration["Authentication:AzureAd:ClientId"],
Authority = Configuration["Authentication:AzureAd:AADInstance"] + Configuration["Authentication:AzureAd:TenantId"],
CallbackPath = "/signin-oidc",
ResponseType = "id_token",
TokenValidationParameters = new TokenValidationParameters {
NameClaimType = "name",
RoleClaimType = "role",
}
});
`
Any clue how to resolve this?