Skip to content

Conversation

@bearx3f
Copy link

@bearx3f bearx3f commented Aug 29, 2025

From #7651 After I tested the latest pull request, which I'd previously said passed, the proxy server still couldn't sign the certificate when deployed with the actual application. This was because the server didn't receive the remote server in the correct domain:port format, such as example.com:443. In this patch, I've fixed the CONNECT request to be correct.

I noticed this by observing the request sent by Curl, which sends:

CONNECT example.com:443 HTTP/1.0
Host: example.com:443

Originally, Libtorrent was sending:

CONNECT 23.220.75.232:443 HTTP/1.0
Host: example.com

In this original request, the Host header was missing the port, and the CONNECT method was sending an IP address instead of a domain name.

Copilot AI review requested due to automatic review settings August 29, 2025 03:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the HTTP CONNECT header formatting for proxy connections to ensure proper SSL certificate verification. The changes address issues where the server was receiving IP addresses instead of domain names and missing port numbers in Host headers.

  • Modified the CONNECT request logic to use domain names instead of IP addresses when available
  • Added proper port number formatting to Host headers following HTTP standards
  • Implemented IPv6 address handling for bracketed and non-bracketed formats

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@bearx3f bearx3f force-pushed the send_host_in_connect_fix branch from d1a69ea to 74223e9 Compare August 29, 2025 15:42
Copy link
Owner

@arvidn arvidn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in your description there's also a difference in the host: header. but this is not important then?

@bearx3f bearx3f force-pushed the send_host_in_connect_fix branch 2 times, most recently from 6e11686 to 4257926 Compare September 8, 2025 03:43
@bearx3f bearx3f force-pushed the send_host_in_connect_fix branch from 4257926 to 39d4c39 Compare September 8, 2025 03:44
…t formatting for HTTP CONNECT requests, including IPv6 support and edge case handling; add comprehensive tests for various scenarios
host, port)

# If require_host_header is set, reject requests without Host header
if self.require_host_header and not host_header:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you you remove the check for self.require_host_header (and make it mandatory), you should remove the comment above as well as setting this member to True at the top of the class

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really sorry.

…ce; update logging for Host header checks and add tests for CONNECT requests with/without Host header
@bearx3f bearx3f force-pushed the send_host_in_connect_fix branch from be4f2db to baedd6b Compare September 8, 2025 14:29
@arvidn arvidn closed this Sep 8, 2025
@arvidn arvidn reopened this Sep 8, 2025
@arvidn
Copy link
Owner

arvidn commented Sep 8, 2025

it looks like the simulation error is legitimate and needs to be addressed

…on send_host_in_connect setting; ensure compliance with RFC 9110 and RFC 9112
@bearx3f
Copy link
Author

bearx3f commented Sep 9, 2025

it looks like the simulation error is legitimate and needs to be addressed

The problem is my patch will always send Host header but simulation test check if send_host_in_connect=false host should be empty. I will fix.

@bearx3f bearx3f changed the title fix HTTP CONNECT header Fix Handling of HTTP CONNECT Header in Proxy Connections Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants