Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF HTTPS self-hosted service does not work ("connection to the server was reset")

I have a Self-Hosted (Console App) WCF REST service with the following binding:

  • WebMessageEncodingBindingElement
  • HttpsTransportBindingElement (ManualAddressing=true, KeepAliveEnabled=true, AllowCookies=false, HostNameComparisonMode=Exact)

This is exposed over an HTTPS URL ("https://mylaptop/myendpoint")

I have a self-signed certificate issued to "mylaptop" that I assign using myServiceHost.Credentials.ServiceCertificate.SetCertificate. The certificate is added successfully, and the ServiceHost opens successfully (no exceptions). If I type "netsh http show servicestate", I can see that there's a successful registration at https://mylaptop/myendpoint with HTTP.SYS

However, when I issue a GET to the endpoint, it doesn't work. It seems like the socket is dropped even before a valid HTTP response is obtained. (FireFox says "connection to the server was reset", IE says "cannot display the webpage", and if I do the request through Fiddler it says "connection was forcibly closed by the remote host").

Everything works fine when I use HTTP instead of HTTPS.

Any idea what could be going wrong in the HTTPS case?

like image 533
Eugene Osovetsky Avatar asked Oct 05 '09 19:10

Eugene Osovetsky


2 Answers

You probably need to use httpcfg.exe to reserve your endpoint with HTTP.SYS correctly with a configured X.509 certificate for SSL. The steps to get it done are documented here.

like image 111
tomasr Avatar answered Nov 10 '22 03:11

tomasr


Or use HttpCfgGui- a much friendlier interface to setting up the server certs w/ HTTP.SYS. This is a must-install on all my servers that do HTTP w/ WCF.

like image 23
nitzmahone Avatar answered Nov 10 '22 05:11

nitzmahone