I am trying to configure the WCF service and the client on the same machine with mutual SSL authentication.
I have:
The certificates for the server and client have been created and put them in the LocalMachine certificate store. The private keys of the server and clients are in the Personal store, and the public keys are in the Trusted people store.
I set up the WCF service and the client, each of which indicated its own certificate link from the repository, and also set a link to the certificate of other parties, which will be verified using
<authentication certificateValidationMode="PeerTrust" trustedStoreLocation="LocalMachine" />
Note. Server certificates are issued in the name Machine, and the URL of the service called by the client is "https: \ tokenservice \ tokenservice.svc
In this configuration, I expect the client to connect to the service reliably, either with the end of the resolution of certificates from the Trusted Persons store, but I get the following error, which indicates a failed certificate verification:
[AuthenticationException: The remote certificate is not valid according to the verification procedure.]
So this does not work as I expected. Can anyone point out any errors? Or are my expectations wrong?
WCF configuration below:
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <bindings> <wsHttpBinding> <binding name="CertificateForClient"> <security mode="Transport"> <transport clientCredentialType="Certificate"/> </security> </binding> </wsHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="CertificateBehaviour"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> <serviceCredentials> <clientCertificate> <authentication certificateValidationMode="PeerTrust" trustedStoreLocation="LocalMachine" /> </clientCertificate> <serviceCertificate findValue="CN='ServerCertificate which is machine name'" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectDistinguishedName" /> </serviceCredentials> </behavior> </serviceBehaviors> </behaviors> <services> <service name="TokenService.TokenService" behaviorConfiguration="CertificateBehaviour"> <endpoint contract="TokenService.ITokenService" binding="wsHttpBinding" /> <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"> </endpoint> <host> <baseAddresses> <add baseAddress="https://tokenservice" /> </baseAddresses> </host> </service> </services> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>
Client Configuration:
<system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="ClientBehaviour"> <clientCredentials> <clientCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectDistinguishedName" findValue="CN=TokenClient"/> <serviceCertificate> <authentication certificateValidationMode="PeerTrust" trustedStoreLocation="LocalMachine"></authentication> </serviceCertificate> </clientCredentials> </behavior> </endpointBehaviors> </behaviors> <bindings> <wsHttpBinding> <binding name="ClientBinding"> <security mode="Transport"> <transport clientCredentialType="Certificate"/> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="https://tokenservice/TokenService.svc" behaviorConfiguration="ClientBehaviour" binding="wsHttpBinding" bindingConfiguration="ClientBinding" contract="TokenService.ITokenService" name="ToolClient"> <identity> <dns value="MachineName" /> </identity> </endpoint> </client>
source share