2012-01-13 20 views
6

Próbuję skonfigurować usługę WCF z zabezpieczeniami. Wygenerowałem 2 certyfikaty (po stronie serwera i klienta) przechowywane w LocalComputer \ Personal Certificates. Moja konfiguracja to:Wyjątek: certyfikat klienta nie jest dostępny

Serwer:

<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> 

Klient:

<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> 

otrzymuję wyjątek: Certyfikat klienta nie jest przewidziane. Określ certyfikat klienta w ClientCredentials

Próbowałem wielu tutoriali, ale żaden z nich nie działa. Jakieś sugestie?

Odpowiedz

6

Odpowiedź jest rzeczywiście w wyjątku. Nie masz certyfikatu klienta. Zdefiniować certyfikat usługi dla certyfikatu klienckiego z tym

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

Ale co właściwie powinien zrobić jest zdefiniowanie certyfikatu klienta dla klienta

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

ta powinna przynajmniej rozwiązać wyjątek The client certificate is not provided. Specify a client certificate in ClientCredentials.