aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaime Soriano Pastor <jsoriano@tuenti.com>2013-09-26 12:23:48 +0200
committerJaime Soriano Pastor <jsoriano@tuenti.com>2013-09-26 12:23:48 +0200
commitf33d128a7f27eb2103e511b830c00fe09091c448 (patch)
tree84e656f677f9183a3ad1410e5ef9e22139804426
parent8d954d9965b35eec2e54996c0d6ef5bcc0d40cd6 (diff)
downloadmitmproxy-f33d128a7f27eb2103e511b830c00fe09091c448.tar.gz
mitmproxy-f33d128a7f27eb2103e511b830c00fe09091c448.tar.bz2
mitmproxy-f33d128a7f27eb2103e511b830c00fe09091c448.zip
Reverse proxy works with SSL
-rw-r--r--libmproxy/proxy.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index 75a54192..826726c8 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -414,10 +414,21 @@ class ProxyHandler(tcp.BaseHandler):
)
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)
if line == "":
return None
- scheme, host, port = self.config.reverse_proxy
r = http.parse_init_http(line)
if not r:
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
)
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()
)