mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Reverse proxy works with SSL
This commit is contained in:
parent
8d954d9965
commit
f33d128a7f
@ -414,10 +414,21 @@ class ProxyHandler(tcp.BaseHandler):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def read_request_reverse(self, client_conn):
|
def read_request_reverse(self, client_conn):
|
||||||
|
scheme, host, port = self.config.reverse_proxy
|
||||||
|
if scheme.lower() == "https":
|
||||||
|
if not self.ssl_established:
|
||||||
|
dummycert = self.find_cert(client_conn, host, port, host)
|
||||||
|
sni = HandleSNI(
|
||||||
|
self, client_conn, host, port,
|
||||||
|
dummycert, self.config.certfile or self.config.cacert
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
self.convert_to_ssl(dummycert, self.config.certfile or self.config.cacert, handle_sni=sni)
|
||||||
|
except tcp.NetLibError, v:
|
||||||
|
raise ProxyError(400, str(v))
|
||||||
line = self.get_line(self.rfile)
|
line = self.get_line(self.rfile)
|
||||||
if line == "":
|
if line == "":
|
||||||
return None
|
return None
|
||||||
scheme, host, port = self.config.reverse_proxy
|
|
||||||
r = http.parse_init_http(line)
|
r = http.parse_init_http(line)
|
||||||
if not r:
|
if not r:
|
||||||
raise ProxyError(400, "Bad HTTP request line: %s"%repr(line))
|
raise ProxyError(400, "Bad HTTP request line: %s"%repr(line))
|
||||||
@ -427,7 +438,7 @@ class ProxyHandler(tcp.BaseHandler):
|
|||||||
self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit
|
self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit
|
||||||
)
|
)
|
||||||
return flow.Request(
|
return flow.Request(
|
||||||
client_conn, httpversion, host, port, "http", method, path, headers, content,
|
client_conn, httpversion, host, port, scheme, method, path, headers, content,
|
||||||
self.rfile.first_byte_timestamp, utils.timestamp()
|
self.rfile.first_byte_timestamp, utils.timestamp()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user