Handle HTTPS Request in Proxy Server by C#

Posted by Masoud Zohrabi on Programmers See other posts from Programmers or by Masoud Zohrabi
Published on 2014-06-03T15:34:15Z Indexed on 2014/06/03 15:52 UTC
Read the original article Hit count: 227

Filed under:
|
|
|

I'm trying to write a Home Proxy Server in C# and I almost succeeded but I have problem to handle HTTPS requests (CONNECT).

I don't know really how to handle this type of requests.

In my studies I realized that for this requests we must to connect client to target host directly.

Steps for these requests (that I realized):

  • Receive first request from client (CONNECT https://www.example.ltd:443 HTTP/1.1) and send that to target host
  • Send HTTP/1.1 200 Connection Established\r\n\r\n to client
  • Listen to both sockets (client and target host) and send receives from each other to each other
  • Listen until one of sockets disconnected

Is this correct? If it is, how?

© Programmers or respective owner

Related posts about c#

Related posts about server