{"action":"created","issue":{"url":"https://api.github.com/repos/IdentityServer/IdentityServer4.AccessTokenValidation/issues/18","repository_url":"https://api.github.com/repos/IdentityServer/IdentityServer4.AccessTokenValidation","labels_url":"https://api.github.com/repos/IdentityServer/IdentityServer4.AccessTokenValidation/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/IdentityServer/IdentityServer4.AccessTokenValidation/issues/18/comments","events_url":"https://api.github.com/repos/IdentityServer/IdentityServer4.AccessTokenValidation/issues/18/events","html_url":"https://github.com/IdentityServer/IdentityServer4.AccessTokenValidation/issues/18","id":162384480,"number":18,"title":"Problem when validating JWT token , some requests work some not.","user":{"login":"Tazer","id":132698,"avatar_url":"https://avatars.githubusercontent.com/u/132698?v=3","gravatar_id":"","url":"https://api.github.com/users/Tazer","html_url":"https://github.com/Tazer","followers_url":"https://api.github.com/users/Tazer/followers","following_url":"https://api.github.com/users/Tazer/following{/other_user}","gists_url":"https://api.github.com/users/Tazer/gists{/gist_id}","starred_url":"https://api.github.com/users/Tazer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tazer/subscriptions","organizations_url":"https://api.github.com/users/Tazer/orgs","repos_url":"https://api.github.com/users/Tazer/repos","events_url":"https://api.github.com/users/Tazer/events{/privacy}","received_events_url":"https://api.github.com/users/Tazer/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/IdentityServer/IdentityServer4.AccessTokenValidation/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-06-27T06:49:45Z","updated_at":"2016-07-28T15:03:34Z","closed_at":null,"body":"Hello, I'm getting weird problems when validating the JWT token. The problem is that I can do several requests, then the error just occurs. As you can see there is first 2 logs that the token i successfully validated. then just the error. All these 3 request occur in a very tight time (under 5 seconds) between them with a freshly issued JWT token. So don't understand way it works at first , then just stopped working. and when I restart the app , it works for a while again.\r\n\r\nI'm running the app in docker so it's running under Linux. \r\n\r\n```\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 GET http://sameendpoint/1234\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 GET http://sameendpoint/1234\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 GET http://sameendpoint/1234\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware[1]\r\n      Failed to validate the token {token(removed)}.\r\nMicrosoft.IdentityModel.Tokens.SecurityTokenInvalidSignatureException: IDX10503: Signature validation failed. Keys tried: 'Microsoft.IdentityModel.Tokens.X509SecurityKey , KeyId: {keyId(removed)}\r\n'.\r\nExceptions caught:\r\n 'System.ArgumentNullException: Value cannot be null.\r\nParameter name: SafeHandle cannot be null.\r\n   at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)\r\n   at Interop.Crypto.RsaVerify(Int32 type, Byte[] m, Int32 m_len, Byte[] sigbuf, Int32 siglen, SafeRsaHandle rsa)\r\n   at System.Security.Cryptography.RSAOpenSsl.VerifyHash(Byte[] hash, Byte[] signature, HashAlgorithmName hashAlgorithmName)\r\n   at System.Security.Cryptography.RSAOpenSsl.VerifyHash(Byte[] hash, Byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)\r\n   at System.Security.Cryptography.RSA.VerifyData(Byte[] data, Int32 offset, Int32 count, Byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)\r\n   at System.Security.Cryptography.RSA.VerifyData(Byte[] data, Byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)\r\n   at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.Verify(Byte[] input, Byte[] signature)\r\n   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(Byte[] encodedBytes, Byte[] signature, SecurityKey key, String algorithm)\r\n   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(String token, TokenValidationParameters validationParameters)\r\n'.\r\ntoken: '{\"alg\":\"RS256\",\"typ\":\"JWT\",\"kid\":\"{kid}\"}.{\"nbf\":{nbf}\"exp\":1467013165,\"iss\":\"http://authendpoint\",\"aud\":\"http://authendpoint/resources\",\"client_id\":\"twee.gateway\",\"scope\":\"tempapi\",\"sub\":\"1\",\"auth_time\":1467009565,\"idp\":\"idsrv\",\"email\":\"patrik\",\"amr\":[\"exchange_reference_token\"]}'\r\n   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(String token, TokenValidationParameters validationParameters)\r\n   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)\r\n   at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.<HandleAuthenticateAsync>d__1.MoveNext()\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware[7]\r\n      Bearer was not authenticated. Failure message: IDX10503: Signature validation failed. Keys tried: 'Microsoft.IdentityModel.Tokens.X509SecurityKey , KeyId: {keyid}\r\n      '.\r\n      Exceptions caught:\r\n       'System.ArgumentNullException: Value cannot be null.\r\n      Parameter name: SafeHandle cannot be null.\r\n         at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)\r\n         at Interop.Crypto.RsaVerify(Int32 type, Byte[] m, Int32 m_len, Byte[] sigbuf, Int32 siglen, SafeRsaHandle rsa)\r\n         at System.Security.Cryptography.RSAOpenSsl.VerifyHash(Byte[] hash, Byte[] signature, HashAlgorithmName hashAlgorithmName)\r\n         at System.Security.Cryptography.RSAOpenSsl.VerifyHash(Byte[] hash, Byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)\r\n         at System.Security.Cryptography.RSA.VerifyData(Byte[] data, Int32 offset, Int32 count, Byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)\r\n         at System.Security.Cryptography.RSA.VerifyData(Byte[] data, Byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)\r\n         at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.Verify(Byte[] input, Byte[] signature)\r\n         at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(Byte[] encodedBytes, Byte[] signature, SecurityKey key, String algorithm)\r\n         at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(String token, TokenValidationParameters validationParameters)\r\n      '.\r\n      token: '{\"alg\":\"RS256\",\"typ\":\"JWT\",\"kid\":\"{kid}\"}.{\"nbf\":{nbf},\"exp\":1467013165,\"iss\":\"http://authendpoint\",\"aud\":\"http://authendpoint/resources\",\"client_id\":\"twee.gateway\",\"scope\":\"tempapi\",\"sub\":\"1\",\"auth_time\":1467009565,\"idp\":\"idsrv\",\"email\":\"patrik\",\"amr\":[\"exchange_reference_token\"]}'\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware[3]\r\n      HttpContext.User merged via AutomaticAuthentication from authenticationScheme: Bearer.\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware[3]\r\n      HttpContext.User merged via AutomaticAuthentication from authenticationScheme: Bearer.\r\nwarn: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]\r\n      Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'.\r\ninfo: Microsoft.AspNetCore.Mvc.ChallengeResult[1]\r\n      Executing ChallengeResult with authentication schemes ().\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful for user: 1.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful for user: 1.\r\nfail: Microsoft.AspNetCore.Server.Kestrel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60[13]\r\n      Connection id \"0HKSUAN465EK9\": An unhandled exception was thrown by the application.\r\nSystem.InvalidOperationException: No authentication handler is configured to handle the scheme: Automatic\r\n   at Microsoft.AspNetCore.Http.Authentication.Internal.DefaultAuthenticationManager.<ChallengeAsync>d__11.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Mvc.ChallengeResult.<ExecuteResultAsync>d__14.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Mvc.Internal.FilterActionInvoker.<InvokeResultAsync>d__44.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Mvc.Internal.FilterActionInvoker.<InvokeAsync>d__32.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler.<InvokeActionAsync>d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at twee.cloud.sync.HttpExceptionMiddleware.<Invoke>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationMiddleware.<Invoke>d__7.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Swashbuckle.SwaggerUi.Application.SwaggerUiMiddleware.<Invoke>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Swashbuckle.SwaggerUi.Application.RedirectMiddleware.<Invoke>d__4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Swashbuckle.SwaggerGen.Application.SwaggerGenMiddleware.<Invoke>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 1810.4348ms 200\r\n```"},"comment":{"url":"https://api.github.com/repos/IdentityServer/IdentityServer4.AccessTokenValidation/issues/comments/235922539","html_url":"https://github.com/IdentityServer/IdentityServer4.AccessTokenValidation/issues/18#issuecomment-235922539","issue_url":"https://api.github.com/repos/IdentityServer/IdentityServer4.AccessTokenValidation/issues/18","id":235922539,"user":{"login":"Tazer","id":132698,"avatar_url":"https://avatars.githubusercontent.com/u/132698?v=3","gravatar_id":"","url":"https://api.github.com/users/Tazer","html_url":"https://github.com/Tazer","followers_url":"https://api.github.com/users/Tazer/followers","following_url":"https://api.github.com/users/Tazer/following{/other_user}","gists_url":"https://api.github.com/users/Tazer/gists{/gist_id}","starred_url":"https://api.github.com/users/Tazer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tazer/subscriptions","organizations_url":"https://api.github.com/users/Tazer/orgs","repos_url":"https://api.github.com/users/Tazer/repos","events_url":"https://api.github.com/users/Tazer/events{/privacy}","received_events_url":"https://api.github.com/users/Tazer/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T15:03:34Z","updated_at":"2016-07-28T15:03:34Z","body":"@DeezSmith  I got into the same problem with beta2 , after a day or so running. in a \"beta\" enviroment where there is like 3-4 users accessing the service. So for me the problem doesn't surface directly, it's just after X hours of running I get into problem. So feels that after XX issued jwt tokens I get the problem."}}
{"actor":{"display_login":"Tazer"}}