【发布时间】:2014-01-22 11:12:09
【问题描述】:
我想使用客户端证书来保护我的 WCF 服务,即只应允许来自特定根 CA 的客户端证书调用我的服务。
出于测试目的,我首先创建了一个没有 CA 的客户端证书。我在服务器的证书存储中注册了客户端证书(在当前用户 -> 受信任的人下)。
在 VS2013 中,我在 WCF 服务项目上启用了 SSL,以便拥有一个 HTTPS 端点。我已对服务的以下 Web.config 文件进行了如下调整:
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</clientCertificate>
...
</serviceCredentials>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
此外,我已对我的客户端应用程序的 App.config 文件进行了如下调整:
<clientCredentials>
<clientCertificate findValue="Client" x509FindType="FindBySubjectName" storeLocation="CurrentUser" storeName="TrustedPeople" />
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</serviceCertificate>
</clientCredentials>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1">
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
但是,这不起作用,我收到以下异常消息:
向https://localhost:44300/Service1.svc 发出 HTTP 请求时出错。这可能是由于在 HTTPS 情况下未使用 HTTP.SYS 正确配置服务器证书。这也可能是由于客户端和服务器之间的安全绑定不匹配造成的。
如果我切换到消息安全(而不是传输安全)并切换到 HTTP 协议,一切似乎都可以正常工作。所以我想我错过了一些启用 HTTPS 的步骤?!如何让交通安全发挥作用?
【问题讨论】: