title: SecurityTokenInvalidSignatureException: IDX10511: Signature validation failed
body: <p>SecurityTokenInvalidSignatureException: IDX10511: Signature validation failed. Keys tried: 'Microsoft.IdentityModel.Tokens.RsaSecurityKey, KeyId: 'Development', InternalId: 'RoGk-RvQuBI4Mn1J8hdUpzlEH9v_caW7aALLjFqAoac'. I use .Net Core 5 and JwtBearer package latest version.</p>
  <pre><code>services.AddAuthentication(options =&gt;
              {
                  options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                  options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
                  options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
              })
              .AddJwtBearer(options =&gt;
              {
                  var authenticationSettings = configuration
                      .GetSection(AuthenticationSettings.SectionName)
                      .Get&lt;AuthenticationSettings&gt;();
  
                  options.Authority = authenticationSettings.Authority;
                  options.Audience = authenticationSettings.Audience;
                  options.RequireHttpsMetadata = false;
                  options.TokenValidationParameters = new TokenValidationParameters
                  {
                      ValidateIssuer = true,
                      ValidateAudience = true,
                      ValidateLifetime = true,
                      ClockSkew = TimeSpan.Zero
                  };
  
                  options.Events = new JwtBearerEvents
                  {
                      OnAuthenticationFailed = context =&gt;
                      {
                          Log.Warning(context.Exception, &quot;OnAuthenticationFailed&quot;);
  
                          return Task.CompletedTask;
                      },
                      OnForbidden = context =&gt;
                      {
                          if (context.Result.Failure is not null)
                              Log.Warning(context.Result.Failure, &quot;OnForbidden&quot;);
  
                          return Task.CompletedTask;
                      }
                  };
              });
  </code></pre>
  <p>Sometimes some of my services starting to throw this exception, but other continue to work correctly. All have the same configuration(code above). What is wrong?</p>