Skip to content
ecdsa.com
Microsoft.IdentityModel.JsonWebTokens / System.IdentityModel.Tokens.Jwt (.NET).NET

Error message

IDX10511: Signature validation failed. Keys tried:

Also printed as

  • Bearer error="invalid_token", error_description="The signature is invalid"

The rest of the message lists the keys tried (hidden as `[PII … is hidden]` unless `ShowPII` is on), key counts, where the matched key came from and the `kid`.

Microsoft.IdentityModel.JsonWebTokens / System.IdentityModel.Tokens.Jwt (.NET) — SecurityTokenInvalidSignatureException

What it means

Unlike IDX10503, a key with the token's `kid` was found ("Matched key was in 'TokenValidationParameters'" or "…'Configuration'") — and the signature still did not verify with it. Either two different keys share one key ID, or the token was changed after signing. ASP.NET Core answers with `error_description="The signature is invalid"`.

Why it happens

How to fix it

  1. 1.

    Use thumbprint-based key IDs

    A `kid` computed from the key material (RFC 7638) can only collide if the keys are identical.

    csharp
    // Derive kid from the key itself (RFC 7638 thumbprint) so different keys never share an ID.
    var jwk = JsonWebKeyConverter.ConvertFromECDsaSecurityKey(new ECDsaSecurityKey(ecdsa));
    var key = new ECDsaSecurityKey(ecdsa) { KeyId = Base64UrlEncoder.Encode(jwk.ComputeJwkThumbprint()) };
  2. 2.

    Agree on secret bytes

    Store the shared secret base64-encoded and decode it the same way on both sides.

    csharp
    // HS256: issuer and API must build the key from the same bytes.
    var secret = Convert.FromBase64String(builder.Configuration["Jwt:SecretBase64"]!); // >= 32 bytes
    var signingKey = new SymmetricSecurityKey(secret);

Related errors

Browse the full signature error database