-1

I've created an HTTP Proxy with PHP. It works well for simple HTTP requests where it receives the request, passes it to the target, passes the target's response to the client and closes the connection.

But in the case of TLS requests, when a client sends a CONNECT request, I don't have any idea how can I keep the connection alive and simply create a tunnel which can transfer all the data in two directions.

Are any low level works needed? Or should I use something like a socket connection? If so, how can I do it in PHP?

aynber
  • 22,380
  • 8
  • 50
  • 63
  • 1
    After a successful CONNECT response is sent all what is needed is to read everything from the client and pass it to the target server and read everything from the target server and pass it to the client. It is unknown how to accomplish this with your current code since there is absolutely nothing known about your code except that it is in PHP. But the right approach might involve sockets and socket_select. – Steffen Ullrich Feb 28 '23 at 20:50

1 Answers1

-1

Have you read the details of the TLS protocol? For example - https://en.wikipedia.org/wiki/Transport_Layer_Security#Protocol_details

Is your HTTP proxy completely self-written or does it use some libraries inside itself (CURL, etc.)?

Dimitry
  • 128
  • 1
  • 1
  • I've used cURL but right now my proxy is more simple than it's important whether I used libraries or not. It only receives the request, passes it to the target host and passes back its response, and all are done using simple HTTP interactions, without any sockets or etc. BTW I think there's no need to know TLS since after `CONNECT` request, HTTP proxy will be only an intermediate that transfers raw data (including handshake) between two sides and I'm wondering if should I use socket for this approach or any other way. – Reza Nooralizadeh Mar 01 '23 at 10:32