title: Wcf self hosted service with X.509 certificate connection error
body: <p>I have a self hosted Wcf service running on Windows XP and am attempting to use Certificates for message security.  This is being done via the service and client config files.  Both service and client are running on the same machine and I have created certificates for both using makecert.exe.  This worked fine when I had clientCredentialType="Windows" but when I modified the configuration files to use certificates it no longer works.  The problem is that when I attempt to connect to the service from the client I am getting the following exception:</p>
  
  <p>Exception Type:  System.ServiceModel.Security.SecurityNegotiationException, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</p>
  
  <p>Message:  Incoming binary negotiation has invalid ValueType  <a href="http://schemas.xmlsoap.org/ws/2005/02/trust/tlsnego" rel="nofollow noreferrer">http://schemas.xmlsoap.org/ws/2005/02/trust/tlsnego</a>.</p>
  
  <p>My configuration settings are:</p>
  
  <p>Service config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;wsHttpBinding&gt;
          &lt;binding name="wsHttpBinding0" closeTimeout="00:10:00" sendTimeout="00:10:00"&gt;
            &lt;security&gt;
              &lt;!-- &lt;transport clientCredentialType="Certificate"/&gt; --&gt;
              &lt;message clientCredentialType="Certificate"/&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="CommMgr.ServiceBehavior"&gt;
            &lt;serviceMetadata httpGetEnabled="true" policyVersion="Policy15" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
            &lt;serviceCredentials&gt;
              &lt;clientCertificate&gt;
              &lt;!--
                &lt;authentication certificateValidationMode="PeerTrust"/&gt;
                --&gt;
                &lt;authentication certificateValidationMode="None"/&gt;
              &lt;/clientCertificate&gt;           
              &lt;serviceCertificate findValue="WcfServer" storeLocation="CurrentUser"
                storeName="My" x509FindType="FindBySubjectName" /&gt;
            &lt;/serviceCredentials&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;services&gt;
        &lt;service name="CommMgr.Service" behaviorConfiguration="CommMgr.ServiceBehavior"&gt;
          &lt;endpoint address="http://localhost:8002/Service"
                    binding="wsHttpBinding"
                    name="DataService"
                    bindingNamespace="CommMgr"
                    contract="CommMgr.Service"
                    bindingConfiguration="wsHttpBinding0"&gt;
            &lt;!--
            &lt;identity&gt;
              &lt;dns value="localhost"/&gt;
            &lt;/identity&gt;  
            --&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:8080/Service/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
    &lt;/system.serviceModel&gt;
    &lt;connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Client config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;wsHttpBinding&gt;
                  &lt;binding name="WSHttpBinding_Service" closeTimeout="00:01:00"
                      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                      maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                      messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                      allowCookies="false"&gt;
                      &lt;readerQuotas maxDepth="32" maxStringContentLength="16384" maxArrayLength="16384"
                          maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                      &lt;reliableSession ordered="true" inactivityTimeout="00:10:00"
                          enabled="false" /&gt;
                      &lt;security mode="Message"&gt;
                          &lt;!-- &lt;transport clientCredentialType="Certificate"/&gt; --&gt;
                        &lt;transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /&gt;
                        &lt;message clientCredentialType="Certificate" negotiateServiceCredential="true" 
                                   algorithmSuite="Default" establishSecurityContext="true"/&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/wsHttpBinding&gt;
          &lt;/bindings&gt;
        &lt;behaviors&gt;
          &lt;endpointBehaviors&gt;
            &lt;behavior name="ClientCertificateBehavior"&gt;
              &lt;clientCredentials&gt;
                &lt;clientCertificate findValue="WcfClient" storeLocation="CurrentUser"
                  storeName="My" x509FindType="FindBySubjectName" /&gt;
                &lt;serviceCertificate&gt;
                  &lt;!--
                  &lt;authentication certificateValidationMode="PeerTrust"/&gt;
                  --&gt;
                  &lt;authentication certificateValidationMode="None"/&gt;
                &lt;/serviceCertificate&gt;              
              &lt;/clientCredentials&gt;
            &lt;/behavior&gt;
          &lt;/endpointBehaviors&gt;
        &lt;/behaviors&gt;
          &lt;client&gt;
              &lt;endpoint address="http://localhost:8080/Service" behaviorConfiguration="ClientCertificateBehavior"
                  binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_Service"
                  contract="ServiceReference.Service" name="WSHttpBinding_Service"&gt;
                  &lt;identity&gt;
                      &lt;!-- &lt;dns value="WcfServer" /&gt; --&gt;
                    &lt;certificate encodedValue="MIIBuTCCAWOgAwIBAgIQD6mW56bjgapOill7ECgRMzANBgkqhkiG9w0BAQQFADAWMRQwEgYDVQQDEwtSb290IEFnZW5jeTAeFw0xMDA3MjAxODMwMThaFw0zOTEyMzEyMzU5NTlaMBQxEjAQBgNVBAMTCVdjZkNsaWVudDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAv2p/0NDo4iZU35gN+k7nGXe0LZWdnP9i4MHYD3IsFcZGIamMyXwRT8//3jx+1fs1xEb+8+QbZuj8TXt/7aX6x2kz2O5tynuholP35iObDqOd7nYSXN+70QDrZ/uktPOkLrw/nfrA8sK0aZCZjfiINHCRt/izJIzESOGzDOh1if0CAwEAAaNLMEkwRwYDVR0BBEAwPoAQEuQJLQYdHU8AjWEh3BZkY6EYMBYxFDASBgNVBAMTC1Jvb3QgQWdlbmN5ghAGN2wAqgBkihHPuNSqXDX0MA0GCSqGSIb3DQEBBAUAA0EALA+gVZDyjk4+qL7zAEV8esMX38X5QKGXHxBdd6K1+xApnSU79bRCWI9xU+HZ4rRhRJgtOdGQ1qfc9/WfvWXcYw=="/&gt;
                  &lt;/identity&gt;
              &lt;/endpoint&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>