I have a WCF client / WCF application that relies on secure communication between two machines, and I want to use the x509 certificates installed in the certificate store to identify the server and client with each other. I do this by setting up the binding as <security authenticationMode="MutualCertificate"/> . There is only a client machine.
The server has a certificate issued for the .mydomain.com server installed on the local computer / personal storage, and the client has a certificate issued to the .mydomain.com client installed in the same place. In addition, the server has a public client certificate in the local computer / proxies, and the client has a public server certificate in the local computer / proxies.
Finally, the client is configured to verify the server certificate. I did this using the system.servicemodel/behaviors/endpointBehaviors/clientCredentials/serviceCertificate/defaultCertificate in the configuration file.
So far so good, it all works. My problem is that I want to specify in the server configuration file that only clients who identify with the client.mydomain.com certificate from the trust store of certificates are allowed to connect.
The correct information is available on the server using ServiceSecurityContext , but I am looking for a way to indicate in app.config that WCF should perform this check instead of checking the security context from the code.
Is it possible? Any clues would be appreciated.
By the way, my server configuration file looks like this:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <services> <service name="MyServer.Server" behaviorConfiguration="CertificateBehavior"> <endpoint contract="Contracts.IMyService" binding="customBinding" bindingConfiguration="SecureConfig"> </endpoint> <host> <baseAddresses> <add baseAddress="http://localhost/SecureWcf"/> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior name="CertificateBehavior"> <serviceCredentials> <serviceCertificate storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="server.mydomain.com"/> </serviceCredentials> </behavior> </serviceBehaviors> </behaviors> <bindings> <customBinding> <binding name="SecureConfig"> <security authenticationMode="MutualCertificate"/> <httpTransport/> </binding> </customBinding> </bindings> </system.serviceModel> </configuration>
source share