Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP traffic over HTTPS proxy #126

Closed
barjin opened this issue Jan 4, 2024 · 0 comments · Fixed by #129
Closed

HTTP traffic over HTTPS proxy #126

barjin opened this issue Jan 4, 2024 · 0 comments · Fixed by #129
Assignees
Labels
bug Something isn't working. help wanted Extra attention is needed. t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@barjin
Copy link
Contributor

barjin commented Jan 4, 2024

After looking into this Crawlee issue, it seems that we handle HTTP requests routed through HTTPS proxy (the request to the proxy server goes over TLS) incorrectly.

The logic picking the correct Agent for the proxy / request combination is here (reader - open this, check it out for 10 seconds and come back, please).

This tells us that different requests are routed through different Agents.


Now, can I get another pair of eyes to confirm what is happening with the different Agents in this file?

From what it seems to me:

  • HttpRegularProxyAgent: sends a basic (GET / POST etc.) HTTP (as it extends http.Agent) request to the proxy. The target URL is a part of the pathname.

    This is the reason why the HTTP traffic over HTTPS proxy fails - this Agent is used and tries to send bare HTTP requests to an HTTPS proxy.
  • HttpProxyAgent: opens an HTTP - or HTTPS, depending on the proxy url - CONNECT tunnel to the proxy server and pushes the request through that.
  • HttpsProxyAgent: literally calls HttpProxyAgent, but it extends from the https.Agent. I'm not too sure how this is different from the one above.

It seems we have two attributes to care for:

  • HTTP / HTTPS
  • target url as a part of the pathname / HTTP CONNECT method

The former we can simply solve by checking the proxy/target URL protocols - the latter seems like a thing dependent on the proxy used. Is there any way to find out whether the proxy server supports only the pathname / the CONNECT method? Is one of them (much) more prevalent? Can HTTPS traffic go only over CONNECT? (this I would assume, otherwise it sounds like some really bad MITM opportunity). But even in that case, what do we pick for the (now broken) HTTP request over HTTPS proxy?

@barjin barjin added bug Something isn't working. help wanted Extra attention is needed. labels Jan 4, 2024
@barjin barjin self-assigned this Jan 4, 2024
@B4nan B4nan added the t-tooling Issues with this label are in the ownership of the tooling team. label Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. help wanted Extra attention is needed. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants