大网数据广告活动
域与目录服务

ASP.NET MVC Application Error WIF10201 No Valid Key Mapping Found for SecurityToken

· 52CE 我爱测

This article provides guidance for troubleshooting the error, WIF10201- No valid key mapping found for securityToken.

Summary

This article provides guidance for troubleshooting an authentication issue that occurs in an ASP.NET MVC application that uses both WS-Federation OWIN middleware and Windows Identity Foundation (WIF) to authenticate to Microsoft Entra ID.

Symptoms

The ASP.NET MVC application that was previously working generates the following error message although no changes were made to the application:

Error Details:
Server Error in '/' Application.
WIF10201: No valid key mapping found for securityToken: 'System.IdentityModel.Tokens.X509SecurityToken' and issuer: 'https://sts.windows.net/<Directory ID>/'.

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.

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>/'.

Cause

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:

<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, 
System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<authority name="https://sts.windows.net/<Directory ID>/">
    <keys>
    <add thumbprint="C142E..." />
    <add thumbprint="8BA94..." />
    <add thumbprint="D92E1..." />
    </keys>
    <validIssuers>
    <add name="https://sts.windows.net/<Directory ID>/" />
    </validIssuers>
</authority>
</issuerNameRegistry>

The "WIF10201" error occurs if none of these certificate thumbprints match the one that's used by Entra ID to sign the token.

The Entra ID uses a signing key rollover mechanism 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.

Solution

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.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors (upstream author metadata: kaushika-msft). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 02/05/2025
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。