Return a datetime object from SSLCert notbefore and notafter properties.

This commit is contained in:
Aldo Cortesi 2012-04-03 22:23:07 +12:00
parent c6896d7392
commit b9737ed89e
2 changed files with 7 additions and 5 deletions

View File

@ -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):

View File

@ -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)],
]