不遵守 IIS 客户端证书映射规则

IIS Client Certificate Mapping Rule not being respected

我在 Windows Server 2012 R2 上 运行 IIS 8.5。我已经配置了一个 WebAPI(建立在 ASP.net 上)网站以使用 HTTPS(自签名)和 IIS 客户端证书映射来进行客户端证书身份验证。我正在使用 ManyToOneMapping,我在其中定义了一个本地帐户,该帐户与传入请求的客户端证书相关联。此外,我在映射中定义了一个规则,这样如果证书中的 "Subject" 字段包含特定字符串,那么它应该允许该请求。

现在,当我在 API 应用程序中点击 url 时,Firefox 会提示我 select 要使用的证书(如预期的那样)。当我 select 包含映射规则中定义的字符串的证书之一时,浏览器 still 服务资源。相反,我预计会有一个被禁止的回应。因此,客户端证书映射似乎没有按预期工作。

由于我是 IIS 的新手,我想知道如何才能找到解决这种情况的方法。提前致谢。

这是 applicationhost.config 文件的片段:

<location path="SimpleApi" overrideMode="Allow">
    <system.webServer>
        <security>
            <authentication>
                <iisClientCertificateMappingAuthentication enabled="true" oneToOneCertificateMappingsEnabled="false">
                    <manyToOneMappings>
                        <add name="Authorized Access" description="Some long description" userName="SomeUser" password="[enc:AesProvider:removed:enc]">
                            <rules>
                                <clear />
                                <add certificateField="Subject" certificateSubField="OU" matchCriteria="Admin" />
                            </rules>
                        </add>
                    </manyToOneMappings>
                    <oneToOneMappings />
                </iisClientCertificateMappingAuthentication>
            </authentication>
        </security>
    </system.webServer>
</location>
<location path="SimpleApi">
    <system.webServer>
        <security>
            <access sslFlags="Ssl, SslNegotiateCert, SslRequireCert" />
        </security>
    </system.webServer>
</location>

唯一的可能是您为您的网站启用了其他身份验证机制,而它只是退回到该身份验证机制。

检查您网站在 IIS 中的 Authentication 模块并禁用所有其他身份验证机制。