Merge pull request #2018 from dlenski/save_mitm_cert

This commit is contained in:
Thomas Kriechbaumer 2017-02-21 21:08:28 +01:00
commit 391f28f78c
3 changed files with 9 additions and 2 deletions

View File

@ -17,6 +17,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
address: Remote address address: Remote address
ssl_established: True if TLS is established, False otherwise ssl_established: True if TLS is established, False otherwise
clientcert: The TLS client certificate clientcert: The TLS client certificate
mitmcert: The MITM'ed TLS server certificate presented to the client
timestamp_start: Connection start timestamp timestamp_start: Connection start timestamp
timestamp_ssl_setup: TLS established timestamp timestamp_ssl_setup: TLS established timestamp
timestamp_end: Connection end timestamp timestamp_end: Connection end timestamp
@ -40,6 +41,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
self.clientcert = None self.clientcert = None
self.ssl_established = None self.ssl_established = None
self.mitmcert = None
self.timestamp_start = time.time() self.timestamp_start = time.time()
self.timestamp_end = None self.timestamp_end = None
self.timestamp_ssl_setup = None self.timestamp_ssl_setup = None
@ -72,6 +74,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
address=tcp.Address, address=tcp.Address,
ssl_established=bool, ssl_established=bool,
clientcert=certs.SSLCert, clientcert=certs.SSLCert,
mitmcert=certs.SSLCert,
timestamp_start=float, timestamp_start=float,
timestamp_ssl_setup=float, timestamp_ssl_setup=float,
timestamp_end=float, timestamp_end=float,
@ -98,6 +101,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
return cls.from_state(dict( return cls.from_state(dict(
address=dict(address=address, use_ipv6=False), address=dict(address=address, use_ipv6=False),
clientcert=None, clientcert=None,
mitmcert=None,
ssl_established=False, ssl_established=False,
timestamp_start=None, timestamp_start=None,
timestamp_end=None, timestamp_end=None,
@ -108,9 +112,10 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
tls_version=None, tls_version=None,
)) ))
def convert_to_ssl(self, *args, **kwargs): def convert_to_ssl(self, cert, *args, **kwargs):
super().convert_to_ssl(*args, **kwargs) super().convert_to_ssl(cert, *args, **kwargs)
self.timestamp_ssl_setup = time.time() self.timestamp_ssl_setup = time.time()
self.mitmcert = cert
sni = self.connection.get_servername() sni = self.connection.get_servername()
if sni: if sni:
self.sni = sni.decode("idna") self.sni = sni.decode("idna")

View File

@ -93,6 +93,7 @@ def convert_100_200(data):
def convert_200_300(data): def convert_200_300(data):
data["version"] = (3, 0, 0) data["version"] = (3, 0, 0)
data["client_conn"]["mitmcert"] = None
return data return data

View File

@ -144,6 +144,7 @@ def tclient_conn():
c = connections.ClientConnection.from_state(dict( c = connections.ClientConnection.from_state(dict(
address=dict(address=("address", 22), use_ipv6=True), address=dict(address=("address", 22), use_ipv6=True),
clientcert=None, clientcert=None,
mitmcert=None,
ssl_established=False, ssl_established=False,
timestamp_start=1, timestamp_start=1,
timestamp_ssl_setup=2, timestamp_ssl_setup=2,