0

我有一个读取用户 CAC 卡的 ASP.NET 网页。发布到测试服务器时,它工作正常;但是,在使用 IIS Express 的本地开发环境中,使用 Request.ServerVariables("CERT_SUBJECT") 时会得到空字符串。我能够检索“LOGON_USER”变量,但“CERT_*”都是空字符串。

目前我的项目设置包含

Anonymous Authentication = false
Windows Authentication = true
SSL Enabled = true   // Created the default IIS express cert.  Have also tried false with no luck

此外,我还尝试像这样修改 applicationhost.config

<security>

    <access sslFlags="SslRequireCert"> <!-- originally none -->

</security>

<authentication>

    <anonymousAuthentication enabled="false" userName="" /> <!--originally true-->

    <basicAuthentication enabled="false" />

    <clientCertificateMappingAuthentication enabled="false" />

    <digestAuthentication enabled="false" />

    <iisClientCertificateMappingAuthentication enabled="true"> <!--originally false-->
    </iisClientCertificateMappingAuthentication>

    <windowsAuthentication enabled="true"> <!--originally false-->
        <providers>
            <add value="Negotiate" />
            <add value="NTLM" />
        </providers>
    </windowsAuthentication>

</authentication>

关于我需要进行进一步配置以允许我的开发环境在调试期间看到这些变量的任何想法?谢谢。

4

1 回答 1

0

以下设置证明是正确的。项目属性应设置为

Anonymous Authentication = false
Windows Authentication = true
SSL Enabled = true

和 applicationhost.config 像这样

<access sslFlags="Ssl,SslNegotiateCert,SslRequireCert"> <!-- originally none -->
<anonymousAuthentication enabled="false" userName="" /> <!--originally true-->

<basicAuthentication enabled="false" />

<clientCertificateMappingAuthentication enabled="false" />

<digestAuthentication enabled="false" />

<iisClientCertificateMappingAuthentication enabled="true"> <!--originally false-->
</iisClientCertificateMappingAuthentication>

<windowsAuthentication enabled="true"> <!--originally false-->
    <providers>
        <add value="Negotiate" />
        <add value="NTLM" />
    </providers>
</windowsAuthentication>

此外,在 web 选项卡下的项目设置中,单击 Create Virtual Directory 按钮。

最后,查看项目属性。有一个名为 Ssl URL 的设置。收到。调试时,除非您的项目以 SSL 模式启动,否则它将以常规 http 地址启动并呈现访问禁止错误。将 SSL URL 粘贴到浏览器中,然后按 Enter。该页面现在将提示您输入 CAC 密码,您将能够使用 Request.ServerVariables 查看 CERT 服务器变量。

于 2020-08-05T13:41:57.160 回答