aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-09-08 13:34:08 +0200
committerMaximilian Hils <git@maximilianhils.com>2014-09-08 13:34:08 +0200
commit5a2a5760d09597084e22d184877d3d95ab4122fe (patch)
tree5081e6609c8b4356f979dc0b8f7fd9ac883fed2a /libmproxy/protocol
parent2b2d21aff0bbde86df2fc85fe505f1716bf7b79e (diff)
downloadmitmproxy-5a2a5760d09597084e22d184877d3d95ab4122fe.tar.gz
mitmproxy-5a2a5760d09597084e22d184877d3d95ab4122fe.tar.bz2
mitmproxy-5a2a5760d09597084e22d184877d3d95ab4122fe.zip
improve logging
Diffstat (limited to 'libmproxy/protocol')
-rw-r--r--libmproxy/protocol/http.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index 5d06f1f2..3bd1f3c1 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -990,24 +990,36 @@ class HTTPHandler(ProtocolHandler):
def handle_error(self, error, flow=None):
message = repr(error)
- if "tlsv1 alert unknown ca" in message:
- message += " The client does not trust the proxy's certificate."
+ message_debug = None
if isinstance(error, tcp.NetLibDisconnect):
- self.c.log("TCP connection closed unexpectedly.", "debug")
- else:
- self.c.log("error: %s" % message, level="info")
+ message = None
+ message_debug = "TCP connection closed unexpectedly."
+ elif "tlsv1 alert unknown ca" in message:
+ message = "TLSv1 Alert Unknown CA: The client does not trust the proxy's certificate."
+ elif "handshake error" in message:
+ message_debug = message
+ message = "SSL handshake error: The client may not trust the proxy's certificate."
+
+ if message:
+ self.c.log(message, level="info")
+ if message_debug:
+ self.c.log(message, level="debug")
if flow:
# TODO: no flows without request or with both request and response at the moment.
if flow.request and not flow.response:
- flow.error = Error(message)
+ flow.error = Error(message or message_debug)
self.c.channel.ask("error", flow)
try:
code = getattr(error, "code", 502)
headers = getattr(error, "headers", None)
- self.send_error(code, message, headers)
+
+ html_message = message or ""
+ if message_debug:
+ html_message += "<pre>%s</pre>" % message_debug
+ self.send_error(code, html_message, headers)
except:
pass