aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-04-03 22:23:07 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-04-03 22:23:07 +1200
commitb9737ed89e32fd0f4d5ec842c64e2a1ccc5a9274 (patch)
tree4fd74b5ef88520d4cc05dad71057458a3774a43b /libmproxy
parentc6896d7392efe7147f1e08447fd8861be9eca66c (diff)
downloadmitmproxy-b9737ed89e32fd0f4d5ec842c64e2a1ccc5a9274.tar.gz
mitmproxy-b9737ed89e32fd0f4d5ec842c64e2a1ccc5a9274.tar.bz2
mitmproxy-b9737ed89e32fd0f4d5ec842c64e2a1ccc5a9274.zip
Return a datetime object from SSLCert notbefore and notafter properties.
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/certutils.py8
-rw-r--r--libmproxy/console/flowdetailview.py4
2 files changed, 7 insertions, 5 deletions
diff --git a/libmproxy/certutils.py b/libmproxy/certutils.py
index f393648d..95dcc0fe 100644
--- a/libmproxy/certutils.py
+++ b/libmproxy/certutils.py
@@ -1,4 +1,4 @@
-import os, ssl, hashlib, socket, time
+import os, ssl, hashlib, socket, time, datetime
from pyasn1.type import univ, constraint, char, namedtype, tag
from pyasn1.codec.der.decoder import decode
import OpenSSL
@@ -157,11 +157,13 @@ class SSLCert:
@property
def notbefore(self):
- return self.cert.get_notBefore()
+ t = self.cert.get_notBefore()
+ return datetime.datetime.strptime(t, "%Y%m%d%H%M%SZ")
@property
def notafter(self):
- return self.cert.get_notAfter()
+ t = self.cert.get_notAfter()
+ return datetime.datetime.strptime(t, "%Y%m%d%H%M%SZ")
@property
def has_expired(self):
diff --git a/libmproxy/console/flowdetailview.py b/libmproxy/console/flowdetailview.py
index 6c5e7fe2..e589d01d 100644
--- a/libmproxy/console/flowdetailview.py
+++ b/libmproxy/console/flowdetailview.py
@@ -55,8 +55,8 @@ class FlowDetailsView(urwid.ListBox):
text.append(urwid.Text([("head", "Server Certificate:")]))
parts = [
["Type", "%s, %s bits"%c.keyinfo],
- ["Valid to", c.notafter],
- ["Valid from", c.notbefore],
+ ["Valid to", str(c.notafter)],
+ ["Valid from", str(c.notbefore)],
["Serial", str(c.serial)],
]