From 5c0d70083944e6063cf7b4325d73a3c4a69c3f8a Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 17 Jun 2021 20:02:32 +0200 Subject: [PATCH 1/2] fix #4642 --- mitmproxy/addons/next_layer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mitmproxy/addons/next_layer.py b/mitmproxy/addons/next_layer.py index 622bb93a0..c54171333 100644 --- a/mitmproxy/addons/next_layer.py +++ b/mitmproxy/addons/next_layer.py @@ -115,9 +115,13 @@ class NextLayer: # 2. Check for TLS if client_tls: # client tls usually requires a server tls layer as parent layer, except: - # - reverse proxy mode manages this itself. # - a secure web proxy doesn't have a server part. - if s(modes.ReverseProxy) or s(modes.HttpProxy): + # - reverse proxy mode manages this itself. + if ( + s(modes.HttpProxy) or + s(modes.ReverseProxy) or + s(modes.ReverseProxy, layers.ServerTLSLayer) + ): return layers.ClientTLSLayer(context) else: # We already assign the next layer here os that ServerTLSLayer From c075d33997f475e106485bb9db5b9bef75f4beb6 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 17 Jun 2021 20:02:40 +0200 Subject: [PATCH 2/2] minor style fix --- mitmproxy/addons/next_layer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mitmproxy/addons/next_layer.py b/mitmproxy/addons/next_layer.py index c54171333..8b544e315 100644 --- a/mitmproxy/addons/next_layer.py +++ b/mitmproxy/addons/next_layer.py @@ -131,11 +131,11 @@ class NextLayer: return ret # 3. Setup the HTTP layer for a regular HTTP proxy or an upstream proxy. - if any([ - s(modes.HttpProxy), + if ( + s(modes.HttpProxy) or # or a "Secure Web Proxy", see https://www.chromium.org/developers/design-documents/secure-web-proxy - s(modes.HttpProxy, layers.ClientTLSLayer), - ]): + s(modes.HttpProxy, layers.ClientTLSLayer) + ): if ctx.options.mode == "regular": return layers.HttpLayer(context, HTTPMode.regular) else: