aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-10-27 11:38:22 -0700
committerGitHub <noreply@github.com>2016-10-27 11:38:22 -0700
commit97f1236c9951b0cfd7edc0caddac1bdb2446aca5 (patch)
tree1353576cc06dbf4c7cbe63ec33fb24b3c185a8eb
parent2cc4e9210878c7af9ae670808ee54d6b3e91fb64 (diff)
parentd52f35428c835d30b2f2be72d9258a8d908e5072 (diff)
downloadmitmproxy-97f1236c9951b0cfd7edc0caddac1bdb2446aca5.tar.gz
mitmproxy-97f1236c9951b0cfd7edc0caddac1bdb2446aca5.tar.bz2
mitmproxy-97f1236c9951b0cfd7edc0caddac1bdb2446aca5.zip
Merge pull request #1670 from chhsiao90/display-cipher-#582
Resolved #582: display ClientConnection select cipher of TLS
-rw-r--r--mitmproxy/connections.py12
-rw-r--r--mitmproxy/io_compat.py2
-rw-r--r--mitmproxy/tools/console/flowdetailview.py4
-rw-r--r--test/mitmproxy/tutils.py2
4 files changed, 19 insertions, 1 deletions
diff --git a/mitmproxy/connections.py b/mitmproxy/connections.py
index 1c35ec7f..b565be78 100644
--- a/mitmproxy/connections.py
+++ b/mitmproxy/connections.py
@@ -21,6 +21,8 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
timestamp_ssl_setup: TLS established timestamp
timestamp_end: Connection end timestamp
sni: Server Name Indication sent by client during the TLS handshake
+ cipher_name: The current used cipher
+ tls_version: TLS version
"""
def __init__(self, client_connection, address, server):
@@ -42,6 +44,8 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
self.timestamp_ssl_setup = None
self.protocol = None
self.sni = None
+ self.cipher_name = None
+ self.tls_version = None
def __bool__(self):
return bool(self.connection) and not self.finished
@@ -64,6 +68,8 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
timestamp_ssl_setup=float,
timestamp_end=float,
sni=str,
+ cipher_name=str,
+ tls_version=str,
)
def copy(self):
@@ -90,13 +96,17 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
timestamp_start=None,
timestamp_end=None,
timestamp_ssl_setup=None,
- sni=None
+ sni=None,
+ cipher_name=None,
+ tls_version=None,
))
def convert_to_ssl(self, *args, **kwargs):
super().convert_to_ssl(*args, **kwargs)
self.timestamp_ssl_setup = time.time()
self.sni = self.connection.get_servername()
+ self.cipher_name = self.connection.get_cipher_name()
+ self.tls_version = self.connection.get_protocol_version_name()
def finish(self):
super().finish()
diff --git a/mitmproxy/io_compat.py b/mitmproxy/io_compat.py
index ea0e2dee..e1ca27b2 100644
--- a/mitmproxy/io_compat.py
+++ b/mitmproxy/io_compat.py
@@ -67,6 +67,8 @@ def convert_017_018(data):
def convert_018_019(data):
data["version"] = (0, 19)
data["client_conn"]["sni"] = None
+ data["client_conn"]["cipher_name"] = None
+ data["client_conn"]["tls_version"] = None
return data
diff --git a/mitmproxy/tools/console/flowdetailview.py b/mitmproxy/tools/console/flowdetailview.py
index a3f07cd5..6e6ca1eb 100644
--- a/mitmproxy/tools/console/flowdetailview.py
+++ b/mitmproxy/tools/console/flowdetailview.py
@@ -82,8 +82,12 @@ def flowdetails(state, flow):
parts = [
["Address", repr(cc.address)],
]
+ if cc.tls_version:
+ parts.append(["TLS Version", cc.tls_version])
if cc.sni:
parts.append(["Server Name Indication", cc.sni])
+ if cc.cipher_name:
+ parts.append(["Cipher Name", cc.cipher_name])
text.extend(
common.format_keyvals(parts, key="key", val="text", indent=4)
diff --git a/test/mitmproxy/tutils.py b/test/mitmproxy/tutils.py
index 9db65e00..5f1dda53 100644
--- a/test/mitmproxy/tutils.py
+++ b/test/mitmproxy/tutils.py
@@ -133,6 +133,8 @@ def tclient_conn():
timestamp_ssl_setup=2,
timestamp_end=3,
sni="address",
+ cipher_name="cipher",
+ tls_version="TLSv1.2",
))
c.reply = controller.DummyReply()
return c