如何将新 JWT 处理程序库 (System.IdentityModel.Tokens.Jwt) 的 1.0.0 版集成到 ASP.NET MVC 4 应用程序中,以处理来自 ACS 的 Azure JWT 令牌?
当我尝试运行我的应用程序时收到以下错误:
[SecurityTokenValidationException: Jwt10329: 无法验证签名,Configuration.IssuerTokenResolver.ResolveToken 返回 null。jwt.Header.SigningKeyIdentifier: 'SecurityKeyIdentifier (IsReadOnly = False, Count = 2, Clause[0] = X509ThumbprintKeyIdentifierClause(Hash = 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX), Clause[1] = System.IdentityModel.Tokens.NamedKeySecurityKeyIdentifierClause) '.] System.IdentityModel.Tokens .JwtSecurityTokenHandler.ValidateSignature(JwtSecurityToken jwt) +1275
System.IdentityModel.Tokens.JwtSecurityTokenHandler.ValidateToken(JwtSecurityToken jwt) +113
System.IdentityModel.Tokens.JwtSecurityTokenHandler.ValidateToken(SecurityToken token) +339
System.IdentityModel.Tokens.SecurityTokenHandlerCollection.ValidateToken(SecurityToken token) +73
System.IdentityModel.Services.TokenReceiver.AuthenticateToken(SecurityToken token, Boolean ensureBearerToken, String endpointUri) +120
System.IdentityModel.Services.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequestBase request) + 493
System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args) +364
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&同步完成)+69
我的 web.config 配置如下:
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="http://127.0.0.1:81/" />
</audienceUris>
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<trustedIssuers>
<add thumbprint="PRIVATEKEY"
name="https://CUSTOM.accesscontrol.windows.net/" />
</trustedIssuers>
</issuerNameRegistry>
<securityTokenHandlers>
<add type="System.IdentityModel.Tokens.JwtSecurityTokenHandler, System.IdentityModel.Tokens.Jwt" />
<securityTokenHandlerConfiguration>
<certificateValidation certificateValidationMode="PeerTrust" />
</securityTokenHandlerConfiguration>
<add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</securityTokenHandlers>
</identityConfiguration>
</system.identityModel>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" />
<wsFederation passiveRedirectEnabled="false" issuer="https://staging.accesscontrol.windows.net/v2/wsfederation" realm="http://127.0.0.1:81/" requireHttps="false" />
</federationConfiguration>
</system.identityModel.services>
我已将 Azure ACS 设置为返回 JWT 令牌并在 web.config 中设置了正确的安全缩略图,但我很困惑为什么会发生此错误。有什么见解吗?