Question

Background - I can get HttpListener working fine for HTTP traffic. I'm having trouble with HTTPS traffic however.

QUESTION: How can I change the code below so that a browser request to a "https" URL will actually be picked up by my HttpListener?

Notes - At the moment with firefox's proxy settings set to "localhost:8080", when I listen to traffic on port 8080 ("https://*:8080/"), and I enter a HTTPS url in firefox, I am getting no traffic being picked up? (when I listen to just http and enter normal http url's it works fine)

  _httpListener = new HttpListener();
  _httpListener.Prefixes.Add("https://*:8080/");
  _httpListener.Start();

thanks

Was it helpful?

Solution

From MSDN

If you create an HttpListener using https, you must select a Server Certificate for that listener. Otherwise, an HttpWebRequest query of this HttpListener will fail with an unexpected close of the connection.

You can configure Server Certificates and other listener options by using HttpCfg.exe. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/http/http/httpcfg_exe.asp for more details. The executable is shipped with Windows Server 2003, or can be built from source code available in the Platform SDK.

Not sure 100% though...

OTHER TIPS

It sounds like Firefox may not be proxying HTTPS traffic like you expect. Does your HTTPS request actually render in the browser (even though no traffic shows up in your HTTPListener)?

Make sure your Firefox browser is set up to proxy SSL to the same location as HTTP, or else make sure the "Use this proxy for all server protocols" box is checked.

Check the FW settings if it passes that port at all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top