【问题标题】:WCF certificate chain trust authentication: "The caller was not authenticated by the service."WCF 证书链信任身份验证:“调用者未经服务身份验证。”
【发布时间】:2011-11-11 21:12:14
【问题描述】:

我想在与 WCF 服务通信时使用基于证书的加密和验证。所以我创建了测试证书,“TempCA”作为我的根 CA,“SignedByCA”作为由该 CA 签名的客户端证书。

当我将客户端证书放入“本地计算机\受信任的人”并使用 certificateValidationMode="PeerTrust" 时,服务会识别客户端并且一切都按预期工作。但是通过信任链验证(certificateValidationMode="ChainTrust"),我遇到了错误“调用者没有被服务验证”。

相关服务器端配置:

<behaviors>
      <serviceBehaviors>
        <behavior name="customServiceBehavior">
            [...]
            <serviceCredentials>
                <clientCertificate>
                    <authentication certificateValidationMode="ChainTrust" trustedStoreLocation="LocalMachine" mapClientCertificateToWindowsAccount="false"  />
                </clientCertificate>
                <serviceCertificate findValue="TempCA"
                                    storeLocation="LocalMachine"
                                    storeName="My"
                                    x509FindType="FindBySubjectName" />
            </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
        <wsHttpBinding>
            <binding name="soapBindingConfiguration">
                <security mode="Message">
                    <message clientCredentialType="Certificate" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>

相关客户端配置(其余由“添加服务引用”自动创建):

<endpointBehaviors>
    <behavior name="customClientBehavior">
        <clientCredentials>
            <clientCertificate findValue="SignedByCA" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
        </clientCredentials>
    </behavior>
</endpointBehaviors>

客户端和服务器证书都与它们的私钥一起存储在“本地计算机\个人”中(因为我在 一个计算机上进行测试),并且“TempCA”(我的根证书)是也在“本地计算机\受信任的根证书颁发机构”中。

我在这里缺少什么?有什么可行的例子吗?

【问题讨论】:

    标签: wcf certificate wcf-security ws-security


    【解决方案1】:

    看起来你正在做的事情应该基于this MSDN article 使用 WCF 证书。使用受信任的根证书方法时,您可能希望从个人存储中删除证书。

    如果这也不起作用,则可能是部署根证书还需要将组策略应用于您的计算机。查看this TechNet article. 的“如果您不使用 Microsoft Enterprise 根证书颁发机构并且只想要一组计算机”部分,它说如果不应用组策略,计算机可能不会自动信任根证书。这两篇文章似乎相互矛盾,所以我不确定哪个会起作用。

    【讨论】:

    • 我不在 ActiveDirectory 域中,因此“Windows 设置/安全设置/公钥策略”下没有此类可用的组策略。我也尝试了第一个建议,只将服务器证书放在“受信任的根证书颁发机构”位置,但没有成功。
    【解决方案2】:

    我终于找到了问题所在。必须禁用吊销检查。我的测试 CA 显然没有关联 CRL,因此在这种情况下,WCF 似乎会阻止每个客户端,因为它无法验证。

    <clientCertificate>
        <authentication certificateValidationMode="ChainTrust"
                        revocationMode="NoCheck" ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←
                        [...]  />
    </clientCertificate>
    

    【讨论】:

      猜你喜欢
      • 2018-03-28
      • 2013-07-05
      • 1970-01-01
      • 1970-01-01
      • 2011-01-15
      • 2013-08-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多