【发布时间】: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