From 47651b1ff2e5dd0c788d744dc1b1d5587107f71a Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 28 Jun 2012 14:29:15 +1200 Subject: Serialization and de-serialization of new cert format. --- libmproxy/flow.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'libmproxy') diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 0e5ba0e3..4de8bc96 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -463,12 +463,12 @@ class Response(HTTPMsg): timestamp: Seconds since the epoch """ - def __init__(self, request, httpversion, code, msg, headers, content, der_cert, timestamp=None): + def __init__(self, request, httpversion, code, msg, headers, content, cert, timestamp=None): assert isinstance(headers, ODictCaseless) self.request = request self.httpversion, self.code, self.msg = httpversion, code, msg self.headers, self.content = headers, content - self.der_cert = der_cert + self.cert = cert self.timestamp = timestamp or utils.timestamp() controller.Msg.__init__(self) self.replay = False @@ -538,14 +538,7 @@ class Response(HTTPMsg): self.headers = ODictCaseless._from_state(state["headers"]) self.content = state["content"] self.timestamp = state["timestamp"] - self.der_cert = state["der_cert"] - - def get_cert(self): - """ - Returns a certutils.SSLCert object, or None. - """ - if self.der_cert: - return certutils.SSLCert.from_der(self.der_cert) + self.cert = state["cert"] def _get_state(self): return dict( @@ -554,7 +547,7 @@ class Response(HTTPMsg): msg = self.msg, headers = self.headers._get_state(), timestamp = self.timestamp, - der_cert = self.der_cert, + cert = self.cert.to_pem() if self.cert else None, content = self.content ) @@ -567,7 +560,7 @@ class Response(HTTPMsg): str(state["msg"]), ODictCaseless._from_state(state["headers"]), state["content"], - state.get("der_cert"), + certutils.SSLCert.from_pem(state["cert"]) if state["cert"] else None, state["timestamp"], ) -- cgit v1.2.3