2010-12-14 97 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