带证书身份验证的WCF服务引用

时间:2012-08-31 16:50:47

标签: c# .net wcf x509certificate

我获得了一个wcf服务网址,私有和公共证书来使用它。

My url is https:/xxxx.com/xxxx/xxxx.svc
my private certificate is xxx.pfx
my public certificate is xxxx.cer

当我尝试从客户端应用程序添加服务引用时,它会引发以下错误。

There was an error downloading 
'https://xxxx.com/xxxx/xxxx.svc'.
The underlying connection was closed: 
An unexpected error occurred on a receive.
Unable to read data from the transport connection: 
An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 
'https://xxxx.com/xxxx/xxxx.svc'.
An error occurred while receiving the HTTP response to   
https://xxxx.com/xxxx/xxxx.svc. 
This could be due to the service endpoint binding not using the HTTP protocol. 
This could also be due to an HTTP request context being aborted by the server 
(possibly due to the service shutting down).   
See server logs for more details.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection:
An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
If the service is defined in the current solution, 
try building the solution and adding  the service reference again.

我在个人,受信任的人,受信任的发布者文件夹下安装了证书。我无权访问服务器来检查服务器配置。但我被告知这对不同的客户有用。我确信我正在弄乱证书的安装。如果有人能指出我正确的方向,那就太好了。

谢谢,

也先

2 个答案:

答案 0 :(得分:1)

你必须启用跟踪才能看到服务器上发生了什么。您发布的错误消息更通用。

http://msdn.microsoft.com/en-us/library/ff648360.aspx http://msdn.microsoft.com/en-us/library/ms733025.aspx

答案 1 :(得分:0)

首先尝试从项目中删除服务引用,从web.config中删除system.ServiceModel部分并再次添加服务引用。这将迫使VS完全重建system.ServiceModel部分。如果这没有帮助,则需要额外的wcf客户端配置。 以下是如何正确配置wcf客户端以使用证书的好示例:

http://www.codeproject.com/Articles/28248/Securing-WCF-Services-with-Certificates

如果您在此之后仍然遇到问题,则可能会遗漏一些自定义endpointBehavior。在这种情况下,您应该联系wcf服务提供商。