代码之家  ›  专栏  ›  技术社区  ›  lucidgold

如何将特定页面限制为证书身份验证?

  •  2
  • lucidgold  · 技术社区  · 10 年前

    在我的ASP。NET web应用程序。aspx(设置为我的起始页),以及一个名为SmartCard的新文件夹,其中包含WebForm1.aspx。如何配置Web。配置为在访问SmartCard/WebForm1.aspx时提示用户输入证书,但默认情况下不提示。aspx加载?

    在接受的答案中 this 问题:

    如果您的应用程序托管在IIS中,那么只需在web.config中添加一个部分,说明这些页面需要客户端证书。然后浏览器将向用户请求证书。

    从上面的答案中,我在StackOverflow上查看了更多信息,发现 this 。根据他们接受的答案,我将以下部分放在Web.Config中:

    <location path="SmartCard">
      <system.webServer>
        <security>
          <access sslFlags="SslRequireCert" />
        </security>
     </system.webServer>
    

    然后我修改了applicationHost。在C:\Windows\System32\inetsrv\config(或适合您安装的目录)中进行配置,并更改以下行:

    <section name="access" overrideModeDefault="Deny" />
    

    至:

    <section name="access" overrideModeDefault="Allow" />
    

    然而,我仍然会在站点加载时收到证书提示。我首先得到以下屏幕:

    enter image description here

    单击“继续访问此网站”后,系统会提示我在默认情况下选择证书。aspx加载。然而,我只想在加载SmartCard/WebForm1.aspx时得到选择证书的提示!

    非常感谢您的帮助!


    以下是我在IIS-7中的站点设置:

    SSL设置:

    enter image description here

    网站绑定: enter image description here enter image description here

    *MyDevCert是自签名的


    更新:

    我创建了一个新网站。SmartCard目录内的配置文件包含以下内容:

     <?xml version="1.0"?>
     <configuration>
    
        <security>
           <access sslFlags="SslRequireCert" />
        </security>
        <system.web></system.web>
    
     </configuration>
    

    然后,我从基本Web.Config中删除了“location”标记。

    基本Web配置:

    <?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>
    

    然而,我仍然会看到“此网站的安全证书有问题”屏幕,并且在单击“继续访问此网站”后,我会收到证书提示

    1 回复  |  直到 9 年前
        1
  •  1
  •   Bigsby    10 年前

    从我看到的情况来看 sslFlags .

    看见 http://www.iis.net/configreference/system.webserver/security/access https://msdn.microsoft.com/en-us/library/ms689458(v=VS.90).aspx

    sslFlags属性可以是以下可能的值之一。默认值为“无”。