【发布时间】:2015-10-22 02:40:24
【问题描述】:
在我的 ASP.NET Web 应用程序中,我创建了 Default.aspx(设置为我的起始页)和一个名为 SmartCard 的新文件夹,其中包含 WebForm1.aspx。如何配置 Web.Config 以在访问 SmartCard/WebForm1.aspx 时提示用户输入证书,但在加载 Default.aspx 时不提示?
在this问题的接受答案中:
如果您的应用程序托管在 IIS 中,则只需添加(在 web.config 中)一个部分,说明这些页面需要客户端证书。然后浏览器会要求用户提供证书。
从上面的答案,我在 StackOverflow 上看了一些,发现 this。从他们接受的答案中,我将以下部分放在 Web.Config 中:
<location path="SmartCard">
<system.webServer>
<security>
<access sslFlags="SslRequireCert" />
</security>
</system.webServer>
然后我修改了 C:\Windows\System32\inetsrv\config(或适合您的安装目录)中的 applicationHost.config 并更改了以下行:
<section name="access" overrideModeDefault="Deny" />
到:
<section name="access" overrideModeDefault="Allow" />
但是,我仍然会在加载站点时收到证书提示。我首先得到以下屏幕:
单击“继续访问此网站”后,系统会在加载 Default.aspx 时提示我选择证书。但是,我只想在加载 SmartCard/WebForm1.aspx 时提示选择证书!
非常感谢任何帮助!
这是我在 IIS-7 中的站点设置:
SSL 设置:
*MyDevCert 是自签名的
更新:
我在 SmartCard 目录中创建了一个新的 Web.Config 文件,其中包含以下内容:
<?xml version="1.0"?>
<configuration>
<security>
<access sslFlags="SslRequireCert" />
</security>
<system.web></system.web>
</configuration>
然后我从基本 Web.Config 中删除了“位置”标签。
基础 Web.Config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<identity impersonate="false" />
</system.web>
</configuration>
但是,我仍然收到“此网站的安全证书存在问题”屏幕,并且在单击“继续访问此网站”后提示我输入证书
【问题讨论】:
标签: c# asp.net ssl iis-7 x509certificate