Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDX10500: Signature validation failed. No security keys were provided to validate the signature

I have the following code and when I call the api endpoint I get error Bearer was not authenticated. Failure message: IDX10500: Signature validation failed. No security keys were provided to validate the signature.

services.AddAuthentication(options =>
{
    options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
    options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
    options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(cfg =>
{
    cfg.RequireHttpsMetadata = false;
    cfg.TokenValidationParameters = new TokenValidationParameters
    {
        ValidateAudience = false,
        ValidateIssuer = false,
        ValidateIssuerSigningKey = false
    };
});

Why is this happening if I am setting the ValidateIssuerSigningKey=false ?

like image 502
pantonis Avatar asked Dec 14 '22 09:12

pantonis


1 Answers

Please refer to thread : https://github.com/aspnet/Security/issues/1741

you can set the delegate TokenValidationParameters.SignatureValidator to just return a JwtSecurityToken.

Currently you can't only set ValidateIssuerSigningKey to false to skip the signature validation .As a workaround , you can set the delegate TokenValidationParameters.SignatureValidator to just return a JwtSecurityToken :

ValidateIssuerSigningKey = false,
SignatureValidator = delegate (string token, TokenValidationParameters parameters)
{
    var jwt = new JwtSecurityToken(token);

    return jwt;
},
like image 142
Nan Yu Avatar answered Dec 15 '22 23:12

Nan Yu