I am trying to configure a WCF service with certificate authentication on both the client and the server. I go through hell, looking through all the possible error messages.
The ultimate goal here is to authenticate both parties with certificates. I will issue a specific certificate for each client, which (I hope) will allow me to tell them separately.
So far I have the following configuration files:
Server configuration file
<configuration> <system.serviceModel> <services> <service name="ServiceApiImplementation" behaviorConfiguration="myBehaviour"> <host> <baseAddresses><add baseAddress="http://localhost:9110/MyService"/></baseAddresses> </host> <endpoint address="" binding="wsHttpBinding" contract="IServiceAPI" bindingName="SOAP12Binding"> <identity> <certificateReference findValue="ServerCertificate" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName"/> </identity> </endpoint> </service> </services> <bindings> <wsHttpBinding> <binding name="SOAP12Binding" receiveTimeout="00:02:00" closeTimeout="00:01:00" openTimeout="00:01:00" sendTimeout="00:01:00"> <security mode="Message"> <message clientCredentialType="Certificate" negotiateServiceCredential="false" establishSecurityContext="false" /> </security> </binding> </wsHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="myBehaviour"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> <serviceCredentials> <serviceCertificate findValue="ServerCertificate" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" /> <clientCertificate> <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck"/> </clientCertificate> </serviceCredentials> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration>
Client configuration file
<system.serviceModel> <client> <endpoint address="http://localhost:9110/MyService" binding="wsHttpBinding" bindingConfiguration="SOAP12Binding_IServiceAPI" contract="IServiceAPI" behaviorConfiguration="behaviour1" name="SOAP12Binding_IServiceAPI"> <identity> <certificate encodedValue="xxxxxxxxxxxxx" /> </identity> </endpoint> </client> <behaviors> <endpointBehaviors> <behavior name="behaviour1"> <clientCredentials> <clientCertificate findValue="ClientCertificate" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName"/> <serviceCertificate> <defaultCertificate findValue="ServerCertificate" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" /> <authentication certificateValidationMode="ChainTrust" trustedStoreLocation="LocalMachine" revocationMode="NoCheck" /> </serviceCertificate> </clientCredentials> </behavior> </endpointBehaviors> </behaviors> <bindings> <wsHttpBinding> <binding name="SOAP12Binding_IServiceAPI"> <security mode="Message"> <message clientCredentialType="Certificate" negotiateServiceCredential="false" establishSecurityContext="false" /> </security> </binding> </wsHttpBinding> </bindings> </system.serviceModel>
I created rootCA and a couple of certificates for the client and server, given the appropriate permissions and put them in stores (both LocalMachine and CurrentUSer out of desperation). As far as I know, this bit works.
Problems arise when calling a service. Last error:
An unsecured or incorrectly protected error was received from another party. See Internal FaultException for error code and details.
The message could not be processed. This is most likely because the action "http://tempuri.org/IServiceAPI/MyMethod" is incorrect either because the message contains an invalid or expired security context token or because there is m ismatch between the bindings. The security context symbol will be invalid if the service interrupted the channel due to inactivity. To prevent interruption of unoccupied sessions, prematurely increases the reception timeout for binding to the service endpoint.
Or even (previous error)
Authentication failed for outgoing message. Expected Identity 'Identity (http://schemas.xmlsoap.org/ws/2005/05/identity/right/possessproperty: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn )' for "Endpoint http: // localhost: 9110 / MyService".
Error messages depend on my experiments in the configuration files. Now the client and server are running on the same computer, so at least I expect each application to authenticate another through rootCA.
Please note that I use Message Security and wsHttpBinding because they looked right. I have no big restrictions other than publishing a service that can be used by standard JAVA platforms.
Can someone help me sort out this mess?
Any help would be greatly appreciated.
Hi,