title: BasicHttpBinding with Certificate authentication - error "forbidden"?
body: <p>I'm trying go get WCF server and client mutually authenticate each other using SSL certificates on transport level using BasicHttpBinding. Here's how the server is getting created:</p>
  
  <pre><code>var soapBinding = new BasicHttpBinding() { Namespace = "http://test.com" };
  soapBinding.Security.Mode = BasicHttpSecurityMode.Transport;
  soapBinding.Security.Transport.ClientCredentialType =
      HttpClientCredentialType.Certificate;
  var sh = new ServiceHost(typeof(Service1), uri);
  sh.AddServiceEndpoint(typeof(IService1), soapBinding, "");
  sh.Credentials.ServiceCertificate.SetCertificate(
      StoreLocation.LocalMachine, StoreName.My, 
      X509FindType.FindBySubjectName, "localhost");
  sh.Open();
  </code></pre>
  
  <p>Here's the client:</p>
  
  <pre><code>var binding = new BasicHttpBinding();
  binding.Security.Mode = BasicHttpSecurityMode.Transport;
  var service = new ServiceReference2.Service1Client(binding,
      new EndpointAddress("https://localhost:801/Service1"));
  
  service.ClientCredentials.ClientCertificate.SetCertificate(
      StoreLocation.LocalMachine, StoreName.My, 
      X509FindType.FindBySubjectName, "localhost");
  
  service.ClientCredentials.ServiceCertificate.Authentication.
      CertificateValidationMode =
          System.ServiceModel.Security.X509CertificateValidationMode.PeerTrust;
  
  service.HelloWorld();
  </code></pre>
  
  <p>Certificate for localhost is in Personal, Trusted Root and Trusted 3rd Party containers. Internet Explorer can connect to host and see WSDL. Also, SSL calls work fine with ClientCredentialType = HttpClientCredentialType.None</p>
  
  <p>HelloWorld() fails with:</p>
  
  <pre><code>System.ServiceModel.Security.MessageSecurityException occurred&lt;br/&gt;
    Message="The HTTP request was forbidden with client authentication
    scheme 'Anonymous'."
  </code></pre>
  
  <p>which is a rethrown exception from: "The remote server returned an error: (403) Forbidden."</p>
  
  <p>how does one go around figuring out wtf is going on?</p>