Can't get windows host file to forward HTTPS headers

2

I'm currently trying to write a proxy in C# using the host file to redirect requests (specific request). I only want it to intercept one address.

It's on Windows and the proxy is run locally on the machine.

Ignoring all the other proxy stuff lets just say I'm simply trying to grab the HTTP headers of the first request.

For an HTTP request I set the proxy up at 127.0.0.1:80 and put 127.0.0.1 [foo.com] in the host file.

Open a browser navigate to http://foo.com/ and I grab the request and display it.

"GET foo.com/ HTTP/ 1.1" etc etc

Now if I:

For an HTTPS request I set the proxy up at 127.0.0.1:443 and put 127.0.0.1 [foo.com] in the host file.

Open a browser navigate to https://foo.com/ and I grab the request and display it.

I was expecting "CONNECT ...... etc" but what I actually get is just garbage characters.

If using the same proxy set to 127.0.0.1:8080 and point at it within the browser proxy setting I see the correct HTTPS headers I was expecting.

Why does the host file screw up the HTTPS request headers?

William Humphreys

Posted 2016-03-17T16:51:05.387

Reputation:

Answers

2

It doesn't screw up the headers; you haven't told the OS/browser to use a proxy server, you're telling the OS that the actual server is at 127.0.0.1, so you're receiving the SSL/TLS handshake.

Phil Lello

Posted 2016-03-17T16:51:05.387

Reputation: 234