我正在开发一个网络核心3.1 Web应用程序。身份验证方案之一是证书,因此我想使用客户端证书身份验证来保护页面。这是Web.config IIS配置(很明显,我在解决方案applicationHostConfig中设置了<section name="access" overrideModeDefault="Allow"
):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44300" />
<environmentVariable name="COMPLUS_ForceENC" value="1" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
<location path="certificate/login">
<system.webServer>
<security>
<access sslFlags="Ssl,SslNegotiateCert,SslRequireCert" />
</security>
</system.webServer>
</location>
<system.webServer>
<security>
<access sslFlags="Ssl" />
</security>
</system.webServer>
</configuration>
应用程序成功启动,当我调用localhost:// 33400 / Certificate / login时,浏览器正确显示了证书页面握手,我选择了一个证书,并且... IIS使我感到惊讶404静态文件处理程序!所有其他页面均正常运行。
我正在为这个错误而苦恼,请有人帮助我。
感谢@treborgero在aspnet核心问题Optional client certificates #21193中>
提示:请确保您删除了<location path="." inheritInChildApplications="false">
标签它就像一种魅力!