Skip to content

[ReverseProxyPlugin] Remove redundant ca_file flag when wrapping upstream #1046

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

Merged
merged 5 commits into from
Jan 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion proxy/core/connection/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def connect(
)
self.closed = False

def wrap(self, hostname: str, ca_file: Optional[str]) -> None:
def wrap(self, hostname: str, ca_file: Optional[str] = None) -> None:
ctx = ssl.create_default_context(
ssl.Purpose.SERVER_AUTH, cafile=ca_file,
)
Expand Down
12 changes: 9 additions & 3 deletions proxy/http/server/reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ...core.base import TcpUpstreamConnectionHandler
from ...common.utils import text_
from ...common.constants import (
DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT,
HTTPS_PROTO, DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT,
DEFAULT_REVERSE_PROXY_ACCESS_LOG_FORMAT,
)

Expand Down Expand Up @@ -78,12 +78,18 @@ def handle_request(self, request: HttpParser) -> None:
assert self.upstream
try:
self.upstream.connect()
if self.choice.scheme == b'https':
if self.choice.scheme == HTTPS_PROTO:
self.upstream.wrap(
text_(
self.choice.hostname,
), ca_file=str(self.flags.ca_file),
),
)
# Update Host header
# if request.has_header(b'Host'):
# request.del_header(b'Host')
# request.add_header(
# b'Host', ('%s:%d' % self.upstream.addr).encode('utf-8'),
# )
self.upstream.queue(memoryview(request.build()))
except ConnectionRefusedError:
raise HttpProtocolException(
Expand Down