|
| 1 | +--- |
| 2 | +title: ASP.NET MVC Application Error WIF10201 No Valid Key Mapping Found for SecurityToken |
| 3 | +description: This article provides guidance for troubleshooting the error, "WIF10201- No valid key mapping found for securityToken." |
| 4 | +author: genlin |
| 5 | +ms.author: bachoang |
| 6 | +ms.service: entra-id |
| 7 | +ms.topic: troubleshooting-general |
| 8 | +ms.date: 02/05/2025 |
| 9 | +ms.custom: sap:Issues Signing In to Applications |
| 10 | +--- |
| 11 | + |
| 12 | +# "WIF10201: No valid key mapping found for securityToken" error in ASP.NET application |
| 13 | + |
| 14 | +This article provides guidance for troubleshooting an authentication issue that occurs in an ASP.NET MVC application that uses both [WS-Federation](https://github.com/Azure-Samples/active-directory-dotnet-webapp-wsfederation) OWIN middleware and [Windows Identity Foundation](../../../windows-server/user-profiles-and-logon/windows-identity-foundation.md) (WIF) to authenticate to Microsoft Entra ID. |
| 15 | + |
| 16 | +## Symptoms |
| 17 | + |
| 18 | +The ASP.NET MVC application that was previously working generates the following error message although no changes were made to the application: |
| 19 | + |
| 20 | +``` |
| 21 | +Error Details: |
| 22 | +Server Error in '/' Application. |
| 23 | +WIF10201: No valid key mapping found for securityToken: 'System.IdentityModel.Tokens.X509SecurityToken' and issuer: 'https://sts.windows.net/<Directory ID>/'. |
| 24 | +
|
| 25 | +Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. |
| 26 | +
|
| 27 | +Exception Details: System.IdentityModel.Tokens.SecurityTokenValidationException: WIF10201: No valid key mapping found for securityToken: 'System.IdentityModel.Tokens.X509SecurityToken' and issuer: 'https://sts.windows.net/<Directory ID>/'. |
| 28 | +``` |
| 29 | + |
| 30 | +## Cause |
| 31 | + |
| 32 | +To validate the signature of the token that's returned by the Entra ID after a successful sign-in, WIF uses the certificate thumbprints that are in the Web.config file, as shown in the following example: |
| 33 | + |
| 34 | +```web.config |
| 35 | +<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, |
| 36 | +System.IdentityModel.Tokens.ValidatingIssuerNameRegistry"> |
| 37 | +<authority name="https://sts.windows.net/<Directory ID>/"> |
| 38 | + <keys> |
| 39 | + <add thumbprint="C142E..." /> |
| 40 | + <add thumbprint="8BA94..." /> |
| 41 | + <add thumbprint="D92E1..." /> |
| 42 | + </keys> |
| 43 | + <validIssuers> |
| 44 | + <add name="https://sts.windows.net/<Directory ID>/" /> |
| 45 | + </validIssuers> |
| 46 | +</authority> |
| 47 | +</issuerNameRegistry> |
| 48 | +``` |
| 49 | + |
| 50 | +The "WIF10201" error occurs if none of these certificate thumbprints match the one that's used by Entra ID to sign the token. |
| 51 | + |
| 52 | +The Entra ID uses a [signing key rollover mechanism](/entra/identity-platform/signing-key-rollover) to update the certificate that's used to sign authentication tokens periodically. This key rollover causes the initial certificate thumbprints that are configured in the Web.config file to become invalid. |
| 53 | + |
| 54 | +## Solution |
| 55 | + |
| 56 | +You can either manually update the certificate thumbprints that are in the Web.config file or automate the process through code. For more information, see [Best practices for keys metadata caching and validation](/entra/identity-platform/signing-key-rollover#best-practices-for-keys-metadata-caching-and-validation). |
0 commit comments