1

我已经看到很多关于此的未解决的问题。显然很多开发者已经得到了past这个问题,但我还没有看到任何解决方案发布。请求客户端证书

我正在尝试为我的ASP.NET MVC 5 Web应用程序读取智能卡(X.509 CAC)。当我尝试像这样拉取证书信息时:

var request = HttpContext.Request; 
var cert = request.ClientCertificate; 

该证书具有空值。

问题似乎是我没有提出请求用户证书信息的对话框,就像我在其他网站上看到的那样。 如何公开此对话框?

我在启用SSL的情况下运行它。我对ApplicationHost.config有这个在它:

<authentication> 
     <anonymousAuthentication enabled="false"/> 
     <basicAuthentication enabled="false" /> 
     <clientCertificateMappingAuthentication enabled="false" /> 
     <digestAuthentication enabled="false" /> 
     <iisClientCertificateMappingAuthentication enabled="true" manyToOneCertificateMappingsEnabled="true"> 
     <manyToOneMappings> 
      <add name="Authentication Certificate" 
       enabled="true" 
       permissionMode="Allow" 
       userName="foo" 
       password="bar"> 
       <rules> 
        <add certificateField="Issuer" certificateSubField="CN" matchCriteria="*localhost*" compareCaseSensitive="false" /> 
       </rules> 
      </add> 
     </manyToOneMappings> 
     </iisClientCertificateMappingAuthentication> 
     <windowsAuthentication enabled="false"> 
      <providers> 
       <add value="Negotiate" /> 
       <add value="NTLM" /> 
      </providers> 
     </windowsAuthentication> 
    </authentication> 

这里是我的接入节点:

<access sslFlags="SslRequireCert" /> 

注意:用户名/密码=富/酒吧看起来很可疑。为什么这会在用户方面填充?是否有必要的服务帐户与此相关联?

我也试图简单配置:

<authentication> 
     <anonymousAuthentication enabled="false" userName="" /> 
     <basicAuthentication enabled="false" /> 
     <clientCertificateMappingAuthentication enabled="true" /> 
     <digestAuthentication enabled="false" /> 
     <iisClientCertificateMappingAuthentication enabled="false"> 
     </iisClientCertificateMappingAuthentication> 
     <windowsAuthentication enabled="false"> 
      <providers> 
       <add value="Negotiate" /> 
       <add value="NTLM" /> 
      </providers> 
     </windowsAuthentication> 
    </authentication> 

会发生什么是网页通常呈现,但我没有征求我的客户端证书。

我明显有客户证书,所以我不知道为什么其他网站能够要求他们。

enter image description here

我使用IIS快递10

回答

0

问题是Visual Studio的2015年把它的IIS快递ApplicationHost.config文件在解决方案的子目录中的一个。它位于.vs/config目录中。

我对任何人都遇到了这个问题的建议是:

(1)首先要确保的配置是什么,你认为会工作(SslRequireCert或协商)。如果你知道applicationhost.config文件应该包含什么内容,那么这部分不太可能会阻止你。

(2)其次证书正确设置。我不认为这对我来说是一个问题,但它可能会阻止你阅读这个属性。您应该能够打开mmc(在敲击Windows按钮之后键入mmc),转到证书(或者如果您没有它,则添加管理单元),并确保个人/证书和中间证书/证书或受信任的根证书/证书有您需要的证书。

而且,正如我说:

(3)确保你有正确的对ApplicationHost.config。