-
Notifications
You must be signed in to change notification settings - Fork 0
/
openssldbrow.py
38 lines (30 loc) · 1.09 KB
/
openssldbrow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
__author__ = 'Martijn Braam <[email protected]>'
from datetime import datetime
from certinfo import CertInfo
class OpenSSLDbRow:
(VALID, REVOKED, EXPIRED) = ("Valid", "Revoked", "Expired")
state = ""
expiration_date = ""
revokation_date = ""
serial = ""
filename = ""
subject = ""
certinfo = None
def parse(self, row):
fields = row.split("\t")
if fields[0] == "V":
self.state = OpenSSLDbRow.VALID
elif fields[0] == "R":
self.state = OpenSSLDbRow.REVOKED
else:
self.state = OpenSSLDbRow.EXPIRED
self.expiration_date = datetime.strptime(fields[1][:-1], "%y%m%d%H%M%S")
if fields[2] != "":
self.revokation_date = datetime.strptime(fields[2][:-1], "%y%m%d%H%M%S")
self.serial = fields[3]
self.filename = fields[4]
self.subject = fields[5]
self.certinfo = CertInfo()
self.certinfo.from_dn(self.subject)
def __str__(self):
return "{} (Serial: {}, valid til {})".format(self.subject, self.serial, self.expiration_date.isoformat())