-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?

1
  • 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. Commented Feb 28, 2023 at 20:50

1 Answer 1

-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.)?

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.