Link to home
Start Free TrialLog in
Avatar of Marc Davis
Marc DavisFlag for United States of America

asked on

WCF Service and Mutual Authentication

Hi,

This processes confuses me. With a WCF Service and Mutual Authentication it is said that on the client  there MUST be the service certificate and obviously client cert.  And on the web service server there MUST be the client cert and the service certificate as well.

What is the situation or under what situation, given the web service certificate is not installed on the client, would the client work and interact or consume the web service without any contract faults being thrown or anything indicating service authentication failed?

The web service has something like this:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSSecurityBindings">
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="TestService">
          <serviceMetadata httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="True" />
          <serviceCredentials>
            <clientCertificate>
              <authentication certificateValidationMode="PeerOrChainTrust" />
            </clientCertificate>
            <serviceCertificate findValue="23423D2E2D1" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySerialNumber" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service behaviorConfiguration="TestService" name="TestService">
        <endpoint binding="wsHttpBinding" bindingConfiguration="WSSecurityBindings" name="AtEndPoint" bindingNamespace="TestWebService" contract="TestWebService.ITestService" />
        <endpoint address="mex" contract="IMetadataExchange" binding="wsHttpBinding" bindingConfiguration="WSSecurityBindings" />
      </service>
    </services>
  </system.serviceModel>

Open in new window


If I am able to access the web service with using my client certificate but yet I do not have the service certificate on my client machine then how is it doing mutual authentication?

Any information on this would be greatly appreciated so this is understood.

Thanks
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

you have to understand pki and how it works.
I have my private key and your public key
you have your private key and my public key
I encrypt something to send to you with my private key and your public key you decrypt with my public key and your private key. the converse is also true.
a good walkthrough for a workgroup environment is available @
http://blogs.msdn.com/b/bradleycotier/archive/2011/12/14/mutual-authentication-with-a-iis-hosted-wcf-data-service-installed-in-a-workgroup-environment.aspx
Avatar of Marc Davis

ASKER

Hi David,

No, I think I understand how that works. :-) I even saw that link before yet I think there is a more simple explanation.

The more I think about this and all I believe it's this...if you have an SSL web site where you assigned a cert to the SSL and person, on a browser, accesses it. Or an application (not a browser) accesses it and successfully. That is one-way authentication.

Now, if you have a client the clients needs to provide their CA cert (or self-assigned if we want to entertain that). The client would have the provide the cert with the payload with the payload. The server service is going to check that in the trusted people store. If that cert is there then it's good. That is the two-way authentication. If the cert is NOT there then an exception is thrown to indicate the x.509 cert is not found.

The reference to the:
 <security mode="Transport">
      <transport clientCredentialType="Certificate" />
 </security>

Open in new window

Implies SSL and a client certificate is in the payload.

A call-back could have some justification but more often than not I believe that would be unnecessary and one cannot force a client to implement a call-back and convey the necessity. The only time I can think of the variation and necessity is of a call-back is if the SSL cert and the webservice cert are different. I do not see or believe that is routine and at least not from what I have seen.

In reality, there is really no need to provide the cert to the client. For the purposes of the public key they can get it themselves. All then would have to do is like in IE 11, go to the https site. When you see the padlock, click it, then go to the view certificate and install the certificate. If they want to export from MMC and the Certificate snap-in they can (or however else they choose to do it. )

Would you disagree with what I mentioned?  (Kinda trying convey my observations and thoughts.)
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, I also know that even though there is no presence of a call back when you do the nettrace and capture the ETL or if you do a network capture .cap file or what have you. When you look at it in Wireshark you will see the TLSV1 references with a Key Exchange and Encrypted handshake message.

So, I guess I don't understand your reference to "(OPTIONAL)" because the web service would use that

<security mode="Transport">
      <transport clientCredentialType="Certificate" />
 </security>

Open in new window



And the client would use the:

<clientCredentials>
            <clientCertificate findValue="2ce200cd33[bla...bla..]" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySerialNumber"/>
            <serviceCertificate>
              <authentication  certificateValidationMode="PeerOrChainTrust"/>
            </serviceCertificate>
          </clientCredentials>

Open in new window

That will pass the client certificate which has to be on the server.

That further supports what I was saying.
Thanks for the response! Very much appreciated and helpful!