title: WCF and SSL Mutual Authentication 403 - Forbidden: Access is denied
body: <p>I have created a wcf data service and expose it over HTTP, with SSL required.
  I am trying to have a setup where both the service and the clients are authenticated through certificates (mutual authentication).
  I am using developer certificates.
  so, I added the server's certificate to the client's trusted people store.</p>
  
  <p>but I'm still getting an exception : "403 - Forbidden: Access is denied."</p>
  
  <p>1- Here is my server config :</p>
  
  <pre><code> &lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;webHttpBinding&gt;
              &lt;binding name="webHttpBindingConfig"&gt;
                  &lt;security mode="Transport"&gt;
                      &lt;transport clientCredentialType="Certificate" /&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
  
      &lt;/behaviors&gt;
      &lt;services&gt;
          &lt;service behaviorConfiguration="" name="PricingDataService"&gt;
              &lt;endpoint address="https://MyServiceSecure/MyServiceSecure/MyServiceSecure.svc"
                  binding="webHttpBinding" bindingConfiguration="webHttpBindingConfig"
                  name="webHttpEndpoint" contract="System.Data.Services.IRequestHandler" /&gt;
          &lt;/service&gt;
      &lt;/services&gt;
  </code></pre>
  
  <blockquote>
    <p>How do I make the server to recognise the client's certificate ? (it should be a developer certificate as well).</p>
  </blockquote>
  
  <p>2- Here is my client config :</p>
  
  <pre><code>  &lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;webHttpBinding&gt;
              &lt;binding name="webHttpBindingConfig"&gt;
                  &lt;security mode="Transport"&gt;
                      &lt;transport clientCredentialType="Certificate" /&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="clientCredentialBehavior"&gt;
            &lt;clientCredentials&gt;
              &lt;clientCertificate storeName="TrustedPeople" storeLocation="LocalMachine"
                                  x509FindType="FindBySubjectName" findValue="tempClientcert" /&gt;
            &lt;/clientCredentials&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;client&gt;
          &lt;endpoint address="https://MyServiceSecure/MyServiceSecure/MyServiceSecure.svc"
              binding="webHttpBinding" bindingConfiguration="webHttpBindingConfig"
              contract="System.Data.Services.IRequestHandler" name="" kind=""
              endpointConfiguration="" behaviorConfiguration="clientCredentialBehavior"&gt;
              &lt;identity&gt;
                &lt;dns value="MyServiceSecure"/&gt;
              &lt;/identity&gt;
          &lt;/endpoint&gt;
      &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>3- Here's the code I use to call the wcf code :</p>
  
  <pre><code>&gt; MyServiceContext service = new MyServiceContext (
              new Uri("https://MyServiceSecure/MyServiceSecure/MyServiceSecure.svc"));
  
  service.SendingRequest += this.OnSendingRequest_AddCertificate;
  
  
  //
  private void OnSendingRequest_AddCertificate(object sender, SendingRequestEventArgs args)
      {
          if (null != ClientCertificate)
              (args.Request as HttpWebRequest).ClientCertificates.Add(X509Certificate.CreateFromCertFile(@"C:\Localhost.cer"););
      }
  </code></pre>
  
  <blockquote>
    <p>do I create a certificate on the server and then install it on the client ? </p>
  </blockquote>