2010-12-14 93 views
2

我已经实现了一个测试客户端/服务器,它通过WCF实现了UserName消息验证。它差不多所有的作品,但我已经倒在最后的障碍。没有为目标'###'提供服务证书在ClientCredentials中指定服务证书

我得到一个InvalidOperationException读取

The service certificate is not provided for target 'http://localhost:8732/Design_Time_Addresses/EvalServiceLibrary/Service1/'. Specify a service certificate in ClientCredentials.

谁能有何启示?

感谢

回答

1

听起来像是你需要的安全证书和您的客户端代码不提供要求的证书。 WCF Security

0

您的客户端需要能够通过引用X509certificate进行身份验证,该公钥将用于加密发送到该服务的消息。

服务证书在客户端由ClientCredentials的ServiceCertificate属性标识。错误消息告诉你,你的配置/代码没有正确设置。如果你发布你的代码/配置,我们可能会告诉你什么是错的。

2

包括在你的客户配置文件是这样的:

<client> 
<endpoint address="http://example.com/Myservice.svc" 
     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService" 
     contract="Core.IService" name="WSHttpBinding_IService" behaviorConfiguration="myServiceBehaviour" > 
    <identity> 
    <dns value="SampleServiceCertificate"/> 
    </identity> 
</endpoint> 
</client> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="myServiceBehaviour"> 
      <clientCredentials> 
      <serviceCertificate> 
       <defaultCertificate storeLocation="LocalMachine" storeName="My" findValue="SampleServiceCertificate" x509FindType="FindBySubjectName" /> 
      </serviceCertificate> 
      </clientCredentials> 
     </behavior>    
     </endpointBehaviors>   
    </behaviors> 
+0

你的答案没有工作。我现在收到错误:使用以下搜索条件找不到X.509证书:StoreName'My',StoreLocation'LocalMachine',FindType'FindBySubjectName',FindValue'SampleServiceCertificate'。 – 2015-09-08 18:14:24

+0

@ MichaelS.Miller - StoreName'My'和FindValue'SampleServiceCertificate'只是我给出的例子,您应该修改这些值以匹配您安装的证书。 – BornToCode 2015-09-08 20:09:26

+0

我正在使用我的证书。但是,事实证明,当我向他们询问证书的名称时,有人在电子邮件中拼错了证书的名称,我只是将它复制/粘贴到代码中,而没有看它。一旦我意识到“服务”没有拼写“Servcie”,它运行良好。 – 2015-09-10 15:43:06