如何configurationIIS Express以请求客户端证书

有谁知道如何将IIS Expressconfiguration为需要客户端证书进行访问? 我正在尝试debugging使用客户端证书进行身份validation的有问题的ASP.NET应用程序。

使用IISpipe理器工具并按照Microsoft文档IIS客户端证书映射身份validation<iisClientCertificateMappingAuthentication> 。

示例configuration:

<location path="Default Web Site"> <system.webServer> <security> <authentication> <windowsAuthentication enabled="false" /> <anonymousAuthentication enabled="false" /> <digestAuthentication enabled="false" /> <basicAuthentication enabled="false" /> <iisClientCertificateMappingAuthentication enabled="true" manyToOneCertificateMappingsEnabled="true"> <manyToOneMappings> <add name="Contoso Employees" enabled="true" permissionMode="Allow" userName="Username" password="[enc:AesProvider:57686f6120447564652c2049495320526f636b73:enc]"> <rules> <add certificateField="Subject" certificateSubField="O" matchCriteria="Contoso" compareCaseSensitive="true" /> </rules> </add> </manyToOneMappings> </iisClientCertificateMappingAuthentication> </authentication> <access sslFlags="Ssl, SslNegotiateCert" /> </security> </system.webServer> </location> 

这是Jason Shavers在他的博客中发出的指示。 (但是那个页面不再存在。)Scott Hanselman还谈到了在http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx上启用S​​SL&#x3002; 但是,他并没有指出让网站需要客户证书。

这些是我遵循的指示:

更改applicationhost.config(这里有两个在MyDocuments \ IISExpress \ config和另一个在程序文件\ IIS Express \ AppServer默认情况下,当您在VS 2012中运行IISExpress上的项目时使用您的configuration文件下的另一个可以另一个使用我在本地testing机上做的命令行来运行。)

  1. 更改元素

<access sslFlags =“None”/> to <access sslFlags =“SslNegotiateCert”/>

和元素

<iisClientCertificateMappingAuthentication enabled =“false”> </ iisClientCertificateMappingAuthentication>

<iisClientCertificateMappingAuthentication enabled =“true”> </ iisClientCertificateMappingAuthentication>

接下来的两个步骤都必须在Visual Studio中执行默认情况下,当在VS 2012中创build新项目时,它将创build为IIS Express项目。 转移到VS2012的较旧的项目可能不得不改变该设置。

  1. 在Web选项卡的项目属性页上,更改使用Visual Studio Developer Server以使用本地IIS Web服务器。 (如果你的计算机没有定期的IIS安装(这些无法在这些NMCI机器上完成),应该显示一个灰色的checkbox,指出使用IIS Express。应该有一个项目URL,像http:// Localhost:62714 / (它应该是在Visual Studio Development Server设置下设置为“特定端口”的相同端口(如果已设置)

  2. 然后select解决scheme资源pipe理器中的项目并转到属性选项卡。 (有些时候,在属性出现之前,这样做有两次)。这将有三个属性,默认为false的SSL启用,新项目为空的SSL URL,以及设置为“项目URL“属性选项卡上。

将启用SSL的属性更改为true,并创build一个新的SSL URL。

  1. 复制该SSL URL并返回到项目属性页面,并将其作为新的项目URL粘贴到那里。 我点击“创build虚拟目录”在这一点上,虽然有些博客说,你只需要保存项目并在debugging中运行它是没有必要的。

在“”元素下的applicationhost.config文件中,在启用SSL之前首次运行项目时会创build一个新条目。 它看起来像这样:

  <site name="WebApplication1" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="c:\users\edward.joell\documents\visual studio 2012\Projects\WebApplication1\WebApplication1" /> </application> <bindings> <binding protocol="http" bindingInformation="*:61313:localhost" /> </bindings> </site> 

当你在你的项目上启用SSL时,它应该看起来像这样:

  <site name="WebApplication1" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="c:\users\edward.joell\documents\visual studio 2012\Projects\WebApplication1\WebApplication1" /> </application> <bindings> <binding protocol="http" bindingInformation="*:61313:localhost" /> <binding protocol="https" bindingInformation="*:44313:localhost" /> </bindings> </site> 

(所有443xx端口都保留给SSL项目)。