Skip to content

Conversation

@mmatczuk
Copy link
Contributor

Fixes #510

@mmatczuk mmatczuk requested a review from Choraden as a code owner November 26, 2024 15:50
Before:

$ curl -k -v -x localhost:3128 https://www.google.com
* Host localhost:3128 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:3128...
* Connected to localhost (::1) port 3128
* CONNECT tunnel: HTTP/1.1 negotiated
* allocate connect buffer
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/8.7.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
<
* CONNECT phase completed
* CONNECT tunnel established, response 200
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
* ALPN: server accepted http/1.1
* Server certificate:
*  subject: O=Forwarder Proxy MITM; CN=www.google.com
*  start date: Nov 25 12:31:19 2024 GMT
*  expire date: Nov 27 12:31:19 2024 GMT
*  issuer: C=US; O=Sauce Labs Inc.
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
* using HTTP/1.x
> GET / HTTP/1.1
> Host: www.google.com
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 500 Internal Server Error
< Content-Length: 55
< Content-Type: text/plain; charset=utf-8
< X-Forwarder-Error: forwarder Not Modified
<
forwarder encountered an unexpected error
Not Modified
* Connection #0 to host localhost left intact

After:

$ curl -k -v -x localhost:3128 https://www.google.com
* Host localhost:3128 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:3128...
* Connected to localhost (::1) port 3128
* CONNECT tunnel: HTTP/1.1 negotiated
* allocate connect buffer
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/8.7.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
<
* CONNECT phase completed
* CONNECT tunnel established, response 200
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
* ALPN: server accepted http/1.1
* Server certificate:
*  subject: O=Forwarder Proxy MITM; CN=www.google.com
*  start date: Nov 25 12:47:26 2024 GMT
*  expire date: Nov 27 12:47:26 2024 GMT
*  issuer: C=US; O=Sauce Labs Inc.
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
* using HTTP/1.x
> GET / HTTP/1.1
> Host: www.google.com
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 304 Not Modified
< Accept-Ranges: bytes
< Access-Control-Allow-Credentials: true
< Cache-Control: public, max-age=0
< Content-Encoding: gzip
< Content-Type: text/css; charset=UTF-8
< Date: Mon, 19 Aug 2024 22:25:39 GMT
< Etag: W/"113bc-191043002c8"
< Last-Modified: Tue, 30 Jul 2024 15:09:01 GMT
< Server: monocle/0.24.1
< Strict-Transport-Security: max-age=15552000; includeSubDomains
< Vary: Origin
<
* Connection #0 to host localhost left intact

Fixes #510
Allow asserting any given response.
Enable TestProxyBadGateway in all cases.
Copy link
Contributor

@Choraden Choraden left a comment

Choose a reason for hiding this comment

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

LGTM

@mmatczuk mmatczuk merged commit d3af146 into main Nov 27, 2024
6 checks passed
@mmatczuk mmatczuk deleted the mmt/connect_error branch November 27, 2024 09:28
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.

mitm: handle upstream proxy error responses for CONNECT requests

3 participants