<access sslFlags="SslRequireCert" /> 使用 IIS Express -> HTTP 错误 500.19

<access sslFlags="SslRequireCert" /> using IIS Express -> HTTP Error 500.19

我正在尝试使用 IIS Express 测试客户端证书身份验证。有可能还是我需要使用 IIS?

我修改了我的 web.config 如下:

<configuration>
    <system.webServer>
        <security>
            <access sslFlags="SslRequireCert" />
        </security>
    </system.webServer>
</configuration>

我使用的指南:

https://dotnetcodr.com/2016/01/11/using-client-certificates-in-net-part-1-introduction/

.vs\config\applicationhost.config 看起来像这样,没有 deny 或 allowOverride 设置为 false。:

<security>
    <access sslFlags="None" />
    ...
</security>

错误:

HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".

.vs\config\applicationhost.config 中,我找到了这些行:

<configuration>
    <configSections>
        <sectionGroup name="system.webServer">
            <sectionGroup name="security">
                <section name="access" overrideModeDefault="Deny" />
            </sectionGroup>
        </sectionGroup>
    </configSections>
</configuration>

改成这个,现在可以用了。

<section name="access" overrideModeDefault="Allow" />

完全可以在 IIS Express 中使用 applicationhost.config 完成此操作。 这篇很棒的文章对我有帮助:https://improveandrepeat.com/2017/07/how-to-configure-iis-express-to-accept-ssl-client-certificates/

它正在对 applicationhost.config 进行这两项更改以接受客户端证书并请求它们

<access sslFlags="Ssl, SslNegotiateCert, SslRequireCert" />

<iisClientCertificateMappingAuthentication enabled="true">
            </iisClientCertificateMappingAuthentication>