从Windows服务调用WCF服务时出现证书错误

时间:2013-07-11 11:24:55

标签: c# .net wcf ssl certificate

我在IIS7上托管了一个WCF服务。从Silverlight客户端和C#Windows服务调用此服务。目前一切都在同一台机器上运行。 它使用自签名证书,带有权限.cer文件,我使用certmgr.msc将其导入受信任的根目录

Silverlight应用程序可以很好地调用该服务,但是当Windows服务尝试调用它时,我得到以下异常:

System.ServiceModel.Security.SecurityNegotiationException: Could not establish trust 
relationship for the SSL/TLS secure channel with authority 'localhost'. ---> 
System.Net.WebException: The underlying connection was closed: Could not establish 
trust relationship for the SSL/TLS secure channel. ---> 
System.Security.Authentication.AuthenticationException: The remote certificate is 
invalid according to the validation procedure.    

当浏览器和Silverlight应用可以通过https访问服务时,Windows服务被拒绝访问的原因是什么? 是否可能是因为客户端证书指纹必须与Windows服务相关联?

(正如您所见,我对SSL身份验证的工作方式不熟悉)。

由于

1 个答案:

答案 0 :(得分:0)

我发现了问题。 事实证明我只将CA导入当前用户存储而不是本地计算机存储,因此Windows服务无法找到它。