2012-01-13 47 views
6

我想要安全地配置WCF服務。我已生成存儲在LocalComputer \ Personal Certificates中的兩個證書(用於服務器和客戶端)。我的配置是:例外:沒有提供客戶端證書

服務器:

<netTcpBinding> 
    <binding name="defaultBinding"> 
     <security mode="Transport"> 
     <transport clientCredentialType="Certificate"/> 
     </security> 
    </binding> 
</netTcpBinding> 

<service name="..." behaviorConfiguration="serviceBehavior"> 
    <endpoint address="..." binding="netTcpBinding" bindingConfiguration="defaultBinding" contract="..."> 
     <identity> 
     <dns value="ClientSide"/> 
     </identity> 
    </endpoint> 
</service> 

<behavior name="serviceBehavior"> 
    <serviceCredentials> 
     <serviceCertificate storeLocation="LocalMachine" storeName="My" findValue="ServerSide" x509FindType="FindBySubjectName"/> 
     <clientCertificate> 
      <authentication certificateValidationMode="None" revocationMode="NoCheck"/> 
     </clientCertificate> 
    </serviceCredentials> 
<behavior> 

客戶:

<netTcpBinding> 
    <binding name="defaultBinding"> 
     <security mode="Transport"> 
     <transport clientCredentialType="Certificate"/> 
     </security> 
    </binding> 
</netTcpBinding> 

<endpoint name="..." binding="netTcpBinding" bindingConfiguration="defaultBinding" contract="..." 
      behaviorConfiguration="endpointBehavior"> 
    <identity> 
    <dns value="ServerSide"/> 
    </identity> 
</endpoint> 

<behavior name="endpointBehavior"> 
    <clientCredentials> 
     <serviceCertificate> 
      <authentication certificateValidationMode="None" revocationMode="NoCheck"/> 
     </serviceCertificate> 
     <clientCertificate storeLocation="LocalMachine" storeName="My" findValue="ClientSide" x509FindType="FindBySubjectName"/> 
    </clientCredentials> 
<behavior> 

我得到異常:未提供客戶端證書。在ClientCredentials中指定一個客戶端證書

我已經嘗試了很多教程,但都不起作用。任何建議?

回答

6

答案實際上是在Exception中。 您沒有客戶端證書。您可以定義客戶端證書服務證書與此

<clientCredentials> 
     <serviceCertificate> 
      <authentication certificateValidationMode="None" revocationMode="NoCheck"/> 
     </serviceCertificate> 
     <clientCertificate storeLocation="LocalMachine" storeName="My" findValue="ClientSide" x509FindType="FindBySubjectName"/> 
    </clientCredentials> 

但實際上,應該做的是什麼定義客戶端

​​

客戶端證書至少應該解決您的The client certificate is not provided. Specify a client certificate in ClientCredentials例外。