【问题标题】:restricting access to a web service based on SSL Client certificates (authorization)基于 SSL 客户端证书(授权)限制对 Web 服务的访问
【发布时间】:2011-08-01 03:31:46
【问题描述】:

我有一个需要客户端证书的网站。

我已使用以下内容配置了我的 IIS 网站:

 <location path="MySecureService">
  <system.webServer>
 <security>
  <access sslFlags="SSl, SslRequireCert"/>
  <authentication>
    <anonymousAuthentication enabled="true"/>
    <windowsAuthentication enabled="true"></windowsAuthentication>
    <digestAuthentication enabled="false"/>
    <basicAuthentication enabled="false"/>
    <iisClientCertificateMappingAuthentication enabled="true" oneToOneCertificateMappingsEnabled="true" >
      <oneToOneMappings>
        <add enabled="true" userName="myUsername" password="myPassword"
             certificate=[certificate-blob-here]
             />
      </oneToOneMappings>
    </iisClientCertificateMappingAuthentication>
  </authentication>
</security>

我可以使用“任何”客户端证书访问该网站,该证书具有我的服务器识别的根 CA。如何限制对某些证书的访问?

【问题讨论】:

    标签: c# .net iis ssl certificate


    【解决方案1】:

    听起来你想要的可能是映射客户端证书:

    http://learn.iis.net/page.aspx/478/configuring-one-to-one-client-certificate-mappings/

    另外,我注意到在您的配置中“匿名”设置为 true。我从经验中知道匿名会覆盖 Windows 身份验证,所以我想知道它是否还会覆盖客户端提供 ssl 证书的需要。

    【讨论】:

    • 这正是“iisClientCertificateMappingAuthentication”部分应该做的:将证书映射到用户。
    • 但如果没有将匿名设置为 true,则 Web 应用程序甚至无法启动,它会引发异常:此服务的安全设置需要“匿名”身份验证,但未为托管的 IIS 应用程序启用这项服务。”
    • 您是否能够使用不在受信任 CA 列表中的客户端证书访问该网站?我有一半怀疑您只是在以匿名用户身份进行身份验证。此外,当您向我禁用匿名身份验证标志时,您会遇到异常,即您的 iis 配置和实际应用程序的 .config 文件不同步。应该为他们两个禁用匿名。最后,我之前没有看你对 WindowsAuthentication 的设置,但我几乎可以肯定你只能选择一种身份验证形式(windows 或 client cert),不能同时使用。
    • 不,我无法使用不在受信任 CA 列表中的客户端证书访问该网站。
    猜你喜欢
    • 1970-01-01
    • 2014-02-23
    • 1970-01-01
    • 1970-01-01
    • 2021-01-15
    • 2012-01-10
    • 2014-09-06
    • 1970-01-01
    • 2015-07-17
    相关资源
    最近更新 更多