我们遇到了WCF的问题 - 尝试连接时出现以下错误。对于各种配置有很多建议,尝试过所有我们可以使用的帮助。WCF显示403禁止使用SSL和客户端证书
我们使用HTTPS传输安全性,使用我们从GoDaddy获得的真实SSL证书。当我们浏览网站上的网页时,它似乎已经安装并正常工作。没有身份验证,我们可以正确连接到我们的WCF服务。
对于认证,我们使用我们自己创建的客户端证书。在我们切换到HTTPS之前,这些客户端证书工作正常,当时我们正在使用自签名服务器证书的消息安全性(这很痛苦,因为我们必须让客户端安装服务器证书)。
错误 HTTP请求被禁止,客户端身份验证方案为“匿名”。 内部异常:远程服务器返回错误:(403)禁止
服务器配置文件
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="NewBinding0">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="WcfService1.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="NewBinding0" contract="WcfService1.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" />
</clientCertificate>
<serviceCertificate findValue="....." x509FindType="FindByThumbprint" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add scheme="https" binding="wsHttpBinding" bindingConfiguration="NewBinding0" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
客户端配置文件
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="NewBehavior0">
<clientCredentials>
<clientCertificate findValue="customuser1"
storeName="TrustedPeople" x509FindType="FindBySubjectName" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="NewBinding0">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://www.insertoursitename.com/WcfService1/Service1.svc"
behaviorConfiguration="NewBehavior0" binding="wsHttpBinding"
bindingConfiguration="NewBinding0" contract="ServiceReference1.IService1"
name="wsHttpBinding_IService1" />
</client>
</system.serviceModel>
打开WCF日志记录:http://msdn.microsoft.com/en-us/library/ms733025%28v=vs.110%29.aspx – fejesjoco 2014-12-05 19:47:30
服务器日志没有任何错误,客户端日志有:客户端认证方案“匿名”禁止HTTP请求。 – John 2014-12-05 22:38:28
完整的WCF跟踪会在客户端和服务器端产生大量的信息。如果您的服务器没有日志,那么您实际上并未打开WCF跟踪。或者问题出现在IIS中,并且请求甚至不能到达WCF服务,但即使如此,您应该在客户端上拥有更多的日志。无论如何,请检查IIS服务器是否信任客户端证书(只需在服务器上打开客户端证书)。 – fejesjoco 2014-12-05 23:17:41