aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/proxy/server.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-09-02 18:13:18 +0200
committerMaximilian Hils <git@maximilianhils.com>2014-09-02 18:13:18 +0200
commit1e4e332ef9040928cb0548097e879d8e9a57f3a2 (patch)
tree683623e7801511a561afe521ab4c6b864c387f0a /libmproxy/proxy/server.py
parent1a41c15c039f871d5da85b6ce17e4f3006c4374a (diff)
downloadmitmproxy-1e4e332ef9040928cb0548097e879d8e9a57f3a2.tar.gz
mitmproxy-1e4e332ef9040928cb0548097e879d8e9a57f3a2.tar.bz2
mitmproxy-1e4e332ef9040928cb0548097e879d8e9a57f3a2.zip
improve error handling
Diffstat (limited to 'libmproxy/proxy/server.py')
-rw-r--r--libmproxy/proxy/server.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/libmproxy/proxy/server.py b/libmproxy/proxy/server.py
index 946a301a..092eae54 100644
--- a/libmproxy/proxy/server.py
+++ b/libmproxy/proxy/server.py
@@ -95,7 +95,7 @@ class ConnectionHandler:
# Delegate handling to the protocol handler
protocol_handler(self.conntype)(self).handle_messages()
- except (ProxyError, tcp.NetLibError), e:
+ except ProxyError as e:
protocol_handler(self.conntype)(self).handle_error(e)
except Exception:
import traceback, sys
@@ -190,18 +190,24 @@ class ConnectionHandler:
raise ProxyError(502, "No server connection.")
if self.server_conn.ssl_established:
raise ProxyError(502, "SSL to Server already established.")
- self.server_conn.establish_ssl(self.config.clientcerts, self.sni)
+ try:
+ self.server_conn.establish_ssl(self.config.clientcerts, self.sni)
+ except tcp.NetLibError as v:
+ raise ProxyError(502, repr(v))
if client:
if self.client_conn.ssl_established:
raise ProxyError(502, "SSL to Client already established.")
cert, key = self.find_cert()
- self.client_conn.convert_to_ssl(
- cert, key,
- handle_sni=self.handle_sni,
- cipher_list=self.config.ciphers,
- dhparams=self.config.certstore.dhparams,
- ca_file=self.config.ca_file
- )
+ try:
+ self.client_conn.convert_to_ssl(
+ cert, key,
+ handle_sni=self.handle_sni,
+ cipher_list=self.config.ciphers,
+ dhparams=self.config.certstore.dhparams,
+ ca_file=self.config.ca_file
+ )
+ except tcp.NetLibError as v:
+ raise ProxyError(400, repr(v))
def server_reconnect(self):
address = self.server_conn.address