签名验证失败。无法匹配' kid'

时间:2017-09-11 07:20:10

标签: c# asp.net-core identityserver4

我使用identityserver4进行SSO问题是每当我重新启动identityserver客户端应用程序时第一次获得异常异常消息

  

发生了未处理的异常:未处理的远程故障。   (IDX10501:签名验证失败。无法匹配&#39;孩子&#39;:   &#39; e57439c26753f8a940888050ab3860fa&#39 ;,         令牌:&#39; {&#34; alg&#34;:&#34; RS256&#34;,&#34;典型&#34;:&#34; JWT&#34;,&#34;孩子&#34 ;:&#34; e57439c26753f8a940888050ab3860fa&#34;} {&#34; NBF&#34;:1505114113,&#34;&EXP#34;:1505114413,&#34; ISS&#34;:&#34; {{ 3}}&#34;&#34; AUD&#34;:&#34; empite.rip&#34;&#34;随机数&#34;:&#34; 636407108987016790.OTIyYzNhOGYtZmY1OS00NDQyLThmNDUtYWNkOTA1NDEyM2JmYTlkYWRjNDMtNDRmMC00YmQxLWI2MGQtOTI2MDYzNDYxMTUy&#34;&# 34; IAT&#34;:1505114113,&#34; c_hash&#34;:&#34; Bc0qZ4ezhn0-WB-e9rDp8g&#34;&#34; SID&#34;:&#34; 135b1b1f352674ab3b80846fef6ad0d8&#34;,& #34;子&#34;:&#34; 94e570f7-920f-426E-b0db-e4f871323149&#34;&#34; auth_time&#34;:1505114112,&#34; IDP&#34;:&#34;本地& #34;&#34; AMR&#34;:[&#34; PWD&#34;]}&#39 ;.)   System.AggregateException:未处理的远程故障。 (IDX10501:   签名验证失败。无法匹配孩子&#39;:   &#39; e57439c26753f8a940888050ab3860fa&#39;,令牌:   &#39; {&#34; ALG&#34;:&#34; RS256&#34;&#34;典型值&#34;:&#34; JWT&#34;&#34;小子&#34 ;: &#34; e57439c26753f8a940888050ab3860fa&#34;} {&#34; NBF&#34;:1505114113,&#34;&EXP#34;:1505114413,&#34; ISS&#34;:&#34; {{3} }&#34;&#34; AUD&#34;:&#34; empite.rip&#34;&#34;随机数&#34;:&#34; 636407108987016790.OTIyYzNhOGYtZmY1OS00NDQyLThmNDUtYWNkOTA1NDEyM2JmYTlkYWRjNDMtNDRmMC00YmQxLWI2MGQtOTI2MDYzNDYxMTUy&#34;&#34; IAT&#34;:1505114113,&#34; c_hash&#34;:&#34; Bc0qZ4ezhn0-WB-e9rDp8g&#34;&#34; SID&#34;:&#34; 135b1b1f352674ab3b80846fef6ad0d8&#34;&#34 ;子&#34;:&#34; 94e570f7-920f-426E-b0db-e4f871323149&#34;&#34; auth_time&#34;:1505114112,&#34; IDP&#34;:&#34;本地&#34 ;,&#34; AMR&#34;:[&#34; PWD&#34;]}&#39 ;.)   ---&GT; Microsoft.IdentityModel.Tokens.SecurityTokenSignatureKeyNotFoundException:   IDX10501:签名验证失败。无法匹配孩子&#39;:   &#39; e57439c26753f8a940888050ab3860fa&#39;,令牌:   &#39; {&#34; ALG&#34;:&#34; RS256&#34;&#34;典型值&#34;:&#34; JWT&#34;&#34;小子&#34 ;: &#34; e57439c26753f8a940888050ab3860fa&#34;} {&#34; NBF&#34;:1505114113,&#34;&EXP#34;:1505114413,&#34; ISS&#34;:&#34; {{3} }&#34;&#34; AUD&#34;:&#34; empite.rip&#34;&#34;随机数&#34;:&#34; 636407108987016790.OTIyYzNhOGYtZmY1OS00NDQyLThmNDUtYWNkOTA1NDEyM2JmYTlkYWRjNDMtNDRmMC00YmQxLWI2MGQtOTI2MDYzNDYxMTUy&#34;&#34; IAT&#34;:1505114113,&#34; c_hash&#34;:&#34; Bc0qZ4ezhn0-WB-e9rDp8g&#34;&#34; SID&#34;:&#34; 135b1b1f352674ab3b80846fef6ad0d8&#34;&#34 ;子&#34;:&#34; 94e570f7-920f-426E-b0db-e4f871323149&#34;&#34; auth_time&#34;:1505114112,&#34; IDP&#34;:&#34;本地&#34 ;,&#34; AMR&#34;:[&#34; PWD&#34;]}&#39 ;.   在   System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(字符串   令牌,TokenValidationParameters validationParameters)at   System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(字符串   token,TokenValidationParameters validationParameters,SecurityToken&amp;   validatedToken)at   Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.ValidateToken(字符串   idToken,AuthenticationProperties属性,   TokenValidationParameters validationParameters,JwtSecurityToken&amp; JWT)   在   Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.d__20.MoveNext()   ---内部异常堆栈跟踪结束---在Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler 1.<HandleRemoteCallbackAsync>d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler 1.d__5.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)在System.Runtime.CompilerServices.TaskAwaiter 1.GetResult() at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.<HandleRequestAsync>d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware 1.d__18.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.d__18.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)

所以我将AddTemporarySigningCredential更改为AddDeveloperSigningCredential但是当我重新启动identityserver时仍然会收到错误

如何解决此问题?

1 个答案:

答案 0 :(得分:1)

您的问题可能与此有关。查看official docs

  

在开发过程中,您有时可能会看到一个例外情况   令牌无法验证。这是因为事实   签名密钥材料是在运行中创建的,仅保留在内存中。   客户端和IdentityServer退出时会发生此异常   同步。只需在客户端重复操作,下次即可   元数据已经赶上了,一切都应该恢复正常了。