【问题标题】:WCF Transport security with peertrust and self-signed client certificates具有 peertrust 和自签名客户端证书的 WCF 传输安全性
【发布时间】:2011-03-14 20:39:14
【问题描述】:

我一直在为 WCF 苦苦挣扎,但我似乎无法弄清楚。 我有一个启用了 SSL 的自托管 WCF 服务(使用来自自签名根 CA 的签名证书),到目前为止一切顺利。该服务用于企业对企业的通信,因此证书似乎是最佳解决方案。

(我目前正在使用 WS 绑定,但这只是出于开发目的,因为所有绑定方法都支持(据我所知)客户端证书的传输级别安全性。)

服务的一些相关配置位:

<bindings>
  <wsHttpBinding>
    <binding name="wsHttpBinding">
      <security mode="Transport">
        <transport clientCredentialType="Certificate"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<!-- snip -->

<serviceCredentials>
  <clientCertificate>
     <authentication certificateValidationMode="PeerTrust" trustedStoreLocation="CurrentUser" />
  </clientCertificate>
</serviceCredentials>

当我让客户端使用运行 WCF 服务的用户的“受信任的人”存储中的自签名证书时,它会失败。当我使用由我自己的根 CA 签名的证书时,即使它不在“受信任的人”存储中,它也可以工作。

我期待我能够使用自签名证书,将它们存储在“受信任的人”存储中,然后一切正常。但似乎有一些额外的验证正在进行,我错过了什么吗?有没有更好的办法?

【问题讨论】:

    标签: .net wcf certificate self-signed


    【解决方案1】:

    我遇到了同样的问题,即我的自签名客户端证书将被验证,即使它不在“受信任的人”存储中,尽管验证模式为“PeerTrust”。通过使用以下服务行为,我终于能够将服务限制为接受特定的客户端证书:

    <behaviors>
       <serviceBehaviors>
          <behavior ...>
          ...
             <serviceCredentials>
                <clientCertificate>
                   <authentication certificateValidationMode="PeerTrust"
                                   revocationMode="NoCheck" 
                                   trustedStoreLocation="LocalMachine" />
                   <certificate findValue="NameOfClientCertificate"
                                x509FindType="FindBySubjectName"
                                storeLocation="LocalMachine"
                                storeName="TrustedPeople" />
                </clientCertificate>
             </serviceCredentials>
             ...
          </behavior>
          ...
    

    身份验证元素和证书元素都需要指向正确的存储,在本例中为“LocalMachine”。

    【讨论】:

      【解决方案2】:

      正确,因此,传输安全和证书验证在 WCF 无法控制的较低级别处理。所以所有那些带有自定义验证器等的花哨的东西都不适用于传输安全,只有消息安全。 要在仅使用传输安全性的同时限制来自客户端的访问,您需要设置 CTL(证书信任列表)。以下网站应该会给你一些指导。

      http://www.leastprivilege.com/CertificateBasedAuthenticationAndWCFTransportSecurity.aspx http://viisual.net/configuration/IIS7-CTLs.htm

      【讨论】:

        【解决方案3】:

        我设法使用这些代码行使其工作:

        m_host = gcnew WebServiceHost( IService::typeid, baseAddress );
        ....
        m_host->Credentials->ClientCertificate->Authentication->CertificateValidationMode = X509CertificateValidationMode::Custom;  //PeerTrust did not work here
        m_host->Credentials->ClientCertificate->Authentication->CustomCertificateValidator = System::IdentityModel::Selectors::X509CertificateValidator::PeerTrust;
        

        在我看来像 WCF 错误。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2013-07-14
          • 2010-10-27
          • 2018-08-31
          • 1970-01-01
          • 2011-10-25
          • 1970-01-01
          • 2011-08-10
          相关资源
          最近更新 更多