diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-11 07:16:06 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-11 07:16:06 +1200 |
commit | 1d09a558a76042f79bf7a46880d411e0add1494e (patch) | |
tree | 12fdcc050ae61acd7225dba4faf871b02dda5973 /libmproxy/proxy.py | |
parent | 04d9ec8c3c32a6e53be9f6f05b3ad69ee5af76e4 (diff) | |
download | mitmproxy-1d09a558a76042f79bf7a46880d411e0add1494e.tar.gz mitmproxy-1d09a558a76042f79bf7a46880d411e0add1494e.tar.bz2 mitmproxy-1d09a558a76042f79bf7a46880d411e0add1494e.zip |
Fix a subtle termination condition when there's an error in a WSGI app.
Diffstat (limited to 'libmproxy/proxy.py')
-rw-r--r-- | libmproxy/proxy.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 0d1ad692..0a2aa922 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -158,7 +158,10 @@ class ProxyHandler(tcp.BaseHandler): app = self.server.apps.get(request) if app: - app.serve(request, self.wfile) + err = app.serve(request, self.wfile) + self.log(cc, "Error in wsgi app.", err.split("\n")) + if err: + return else: request = request._send(self.mqueue) if request is None: @@ -234,7 +237,10 @@ class ProxyHandler(tcp.BaseHandler): else: sans = [] if not self.config.no_upstream_cert: - cert = certutils.get_remote_cert(host, port, sni) + try: + cert = certutils.get_remote_cert(host, port, sni) + except tcp.NetLibError, v: + raise ProxyError(502, "Unable to get remote cert: %s"%str(v)) sans = cert.altnames host = cert.cn.decode("utf8").encode("idna") ret = certutils.dummy_cert(self.config.certdir, self.config.cacert, host, sans) |