title: Handshake failed due to unexpected packet format. WCF hosted in Windows Service
body: <p>I have a WCF that is hosted in a windows service.<br>
  My service runs on port 16000 and I am using basicHttpBinding in my app.config file. The service runs fine and I am able to connect to it when using http.
  I later added SSL security to my service, with the following in my windows service code:</p>
  
  <pre><code>myServiceHost = New ServiceHost(type)     
  myServiceHost.Credentials.ServiceCertificate.SetCertificate (StoreLocation.LocalMachine, StoreName.Root, X509FindType.FindByThumbprint, "thumbprint with spaces")
  </code></pre>
  
  <p>The program compiled and the windows service is running without any errors.
  I then bound the SSL certificate to my 16000 port using netsh and instructions in the following link:
  <a href="https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-a-port-with-an-ssl-certificate" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-a-port-with-an-ssl-certificate</a>.<br>
  However, when I am trying to add a reference to access it using https in the url, I am getting the exception: "Handshake failed due to unexpected packet format."<br>
  Here is my app.config file for reference:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" /&gt;
    &lt;/system.web&gt;
      &lt;system.serviceModel&gt;
    &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"&gt;&lt;/serviceHostingEnvironment&gt;
      &lt;behaviors&gt;
          &lt;serviceBehaviors&gt;
              &lt;behavior name="mexBehaviour"&gt;
                 &lt;serviceMetadata httpGetEnabled="true" /&gt;
                &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
              &lt;/behavior&gt;
          &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;services&gt;
          &lt;service behaviorConfiguration="mexBehaviour" name="myService_ClassLib.myService"&gt;             
              &lt;endpoint address="myService" binding="basicHttpBinding" bindingConfiguration=""
                  contract="myService_ClassLib.ImyService" /&gt;            
           &lt;host&gt;
                  &lt;baseAddresses&gt;
                      &lt;add baseAddress="http://localhost:16000" /&gt;                       
                  &lt;/baseAddresses&gt;
              &lt;/host&gt;
          &lt;/service&gt;
      &lt;/services&gt;
  &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Is there anything I am missing that's causing this error?</p>
  
  <p>Thanks,<br>
  Sri</p>