【发布时间】:2015-08-05 06:00:54
【问题描述】:
我有一个使用此类行为的 WCF 服务:
<behavior name="WCFServiceCertificate.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="ChainTrust"/>
</clientCertificate>
<serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
</serviceCredentials>
</behavior>
它使用我由 makecert 创建的名为“localhost”的证书。首先,我创建了根证书颁发机构,然后创建了一个证书。我还生成了一个保存在文件中的客户端证书。
然后,我有一个使用该 Web 服务的客户端应用程序。 App.config 包括:
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IWS">
<security>
<message clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
然后我从文件中加载客户端的证书:
X509Certificate2 client = new X509Certificate2("client.pfx", "pass");
所有证书的东西似乎都做得很好,但是当我想从客户端调用任何服务方法时,它会说:
调用者未经服务验证
有人可以就如何将 SOAP 标头中的证书正确地从客户端传递到服务器给我一些建议吗?我错过了什么?
【问题讨论】:
-
您是如何托管服务的? IIS、窗口服务还是自托管?您是否在商店中正确安装了 CA 和证书?
-
服务托管在 IIS 上。证书按照此处所述完成:jayway.com/2014/09/03/…我将不胜感激任何建议..
-
您是否已将 IIS 配置为使用该证书?
-
我想要实现的是客户端在向服务器发送请求时使用证书。服务器授权这些请求。服务器无需在客户端获得授权。如果我使用消息授权,您能否解释一下是否必须在 IIS 中配置更多内容?
-
试试这个codeproject.com/Articles/18601/…。可能会有所帮助。
标签: c# web-services wcf