diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-08-26 22:00:50 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-08-26 22:00:50 +0200 |
commit | 9c6b3eb58a22817daa576063c3626d7a239e7093 (patch) | |
tree | ab50d2b745c975e5e539a1866e07a20fa15f2577 /libmproxy/protocol2/tls.py | |
parent | 2cfc1b1b4030838f6047f18f8014c91926b414d0 (diff) | |
download | mitmproxy-9c6b3eb58a22817daa576063c3626d7a239e7093.tar.gz mitmproxy-9c6b3eb58a22817daa576063c3626d7a239e7093.tar.bz2 mitmproxy-9c6b3eb58a22817daa576063c3626d7a239e7093.zip |
clean up clienthello parsing
Diffstat (limited to 'libmproxy/protocol2/tls.py')
-rw-r--r-- | libmproxy/protocol2/tls.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libmproxy/protocol2/tls.py b/libmproxy/protocol2/tls.py index 7ef0ad8c..9c8aeb24 100644 --- a/libmproxy/protocol2/tls.py +++ b/libmproxy/protocol2/tls.py @@ -61,7 +61,12 @@ class TlsLayer(Layer): layer() def _get_client_hello(self): - # Read all records that contain the initial Client Hello message. + """ + Peek into the socket and read all records that contain the initial client hello message. + + Returns: + The raw handshake packet bytes, without TLS record header(s). + """ client_hello = "" client_hello_size = 1 offset = 0 @@ -75,10 +80,15 @@ class TlsLayer(Layer): return client_hello def _parse_client_hello(self): + """ + Peek into the connection, read the initial client hello and parse it to obtain ALPN values. + """ + raw_client_hello = self._get_client_hello()[4:] # exclude handshake header. try: - client_hello = ClientHello.parse(self._get_client_hello()[4:]) + client_hello = ClientHello.parse(raw_client_hello) except ConstructError as e: self.log("Cannot parse Client Hello: %s" % repr(e), "error") + self.log("Raw Client Hello:\r\n:%s" % raw_client_hello.encode("hex"), "debug") return for extension in client_hello.extensions: |