2013-04-26 83 views
2

我们有一个客户端DLL试图访问的IIS托管的WCF服务。该服务在IIS中绑定为使用HTTPS,并设置为忽略客户端证书,这很好,但需要SSL导致问题。WCF需要SSL会导致“该HTTP请求被禁止客户端身份验证方案'匿名'”错误?

我真的不明白的是,调用其中一个服务的方法工作得很好,但调用另一个方法不起作用,并且出现以下错误:“HTTP请求被客户端身份验证方案禁止” Anonymous'。System.Net.WebException:远程服务器返回一个错误:(403)禁止。“

这可能是什么原因造成的?我对WCF很新,所以请让我知道我是否缺少任何东西或是否需要更多信息。

下面是一些业务配置代码:

this.Description.Behaviors.Add(new FaultConversionErrorHandler()); 
this.Description.Behaviors.Add(new LoggingErrorHandler()); 

BasicHttpBinding binding = new BasicHttpBinding(); 
binding.Security.Mode = BasicHttpSecurityMode.Transport; 

ServiceEndpoint endpoint = this.AddServiceEndpoint(typeof(ILicenseService), binding, String.Empty); 

SecurityEndpointBehavior securityEndpointBehavior = new SecurityEndpointBehavior(); 
endpoint.Behaviors.Add(securityEndpointBehavior); 

这里是客户端如何引用服务:

EndpointAddress a = new EndpointAddress(licenseServiceUrl); 
Binding b = new BasicHttpBinding(BasicHttpSecurityMode.Transport); 

LicenseServiceClient client = new LicenseServiceClient(b, a); 
client.Endpoint.Behaviors.Add(new SecurityEndpointBehavior()); 
+0

我遇到了一个与你密切的问题([我的问题])(http://stackoverflow.com/questions/16979346/wcf-service-stop-responding-unexpectedly-with-error-client-authentication-schem)) 你解决了你的问题吗?如果是的话,你能帮我解决我的问题吗? – srcnaks 2013-06-07 13:06:03

回答

0

你可以通过改变你的绑定信息解决它。 将TransportClientCredential类型设置为证书以在IIS SSL设置中使用必需的证书。

如果是Ws-Http,它有点不同。 WCF WS-service主机实际上是检查传入的客户端请求证书是否存在于受信任的人员中。 因此,远程证书应该存在于服务器的可信任人员中。

或者添加CustomValidator并覆盖该行为。

相关问题