2011-09-07 57 views
6

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

当我把在“本地计算机\受信任的人”的客户端证书,并使用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”(我的根证书)也在“本地计算机\受信任的根证书颁发机构”中。

我在这里错过了什么?任何工作示例?

回答

5

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

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

好像你应该工作基于this MSDN article使用证书与WCF做什么。使用受信任的根证书方法时,您可能需要从个人存储中删除证书。

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

+0

我不在ActiveDirectory域中,所以在“Windows设置/安全设置/公钥策略”下没有可用的组策略。我也尝试了第一个建议,只将服务器证书放入“受信任的根证书颁发机构”位置,但未成功。 – AndiDog