簡體   English   中英

如何在使用 IIS Express 在 Visual Studio 2015 中進行調試時從 CAC 獲取 Request.ServerVariables(“CERT_SUBJECT”)

[英]How to obtain Request.ServerVariables(“CERT_SUBJECT”) from a CAC while debugging in Visual Studio 2015 with IIS Express

我有一個讀取用戶 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>

關於我需要進行進一步配置以允許我的開發環境在調試期間看到這些變量的任何想法? 謝謝。

以下設置證明是正確的。 項目屬性應設置為

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 選項卡下的項目設置中,單擊創建虛擬目錄按鈕。

最后,查看項目屬性。 有一個設置叫做 Ssl URL。 收到。 調試時,除非您的項目以 SSL 模式啟動,否則它將以常規 http 地址啟動並呈現訪問禁止錯誤。 在瀏覽器中粘貼 Ssl URL 並回車。 該頁面現在將提示您輸入 CAC 密碼,您將能夠使用 Request.ServerVariables 查看 CERT 服務器變量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM