Im trying to create a local windows MITM proxy with C# to deal with a now unsupported application from a company that no longer exists.

The Proxy has to only service one HTTPS domain which is being done by creating a proxy that listens on the local address:port

An entry in the host file is then created i.e. my.single.domain.com.

If I was to connect to this with a browser using its own proxy setting and having no host entry, the browser will send a "CONNECT...etc" to the proxy.

There are many examples for this and I can get this to work fine from these examples. (Titanium.Web.Proxy etc).

When using a host file as described above the ssl/tls handshake is initiated immediately rather than a "CONNECT....etc" being sent. This is because the browser now rightly believes that is the actual server.

Im really stuggling to find a good example of how to deal with this using the C# SslStream option. Most are for simple client server demos and frankly most dont work including MSDNs own examples.

My specific requirement is a browser navigating to

URI: HTTPS:\\my.single.domain.com\ but no other domain to use this proxy so use the host file. (A port forwarder isnt being used because of reasons out of my control)

Where I am able to intercept (MITM) the passing data.

Do I have to create two SslStream connections now?? One to deal with the browser and then a second one to deal with the server.

Just a good basic example would be cool :-)

closed as off-topic by Steffen Ullrich, Deer Hunter, Matthew, Ohnana, Neil Smithline Mar 24 '16 at 14:57

  • This question does not appear to be about Information security within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    This is purely a programming question and should be moved to stackoverflow.com. – Steffen Ullrich Mar 24 '16 at 5:58
  • Tag me when this gets migrated to stackoverflow and I'll write you an answer. – user7933 Mar 24 '16 at 7:57
  • I wasnt sure if I could move it so Ive just recreated it there stackoverflow.com/questions/36198931/… – William Humphreys Mar 24 '16 at 11:20
  • 1
    I'm voting to close this question as off-topic because it has been manually migrated by the user. For future reference, high-rep users can vote to move questions to predefined targets as well as close questions. We were going to do that, but it looks like that's not needed now :) – Ohnana Mar 24 '16 at 11:29

Browse other questions tagged or ask your own question.