CertificatesEnddate - command /usr/bin/openssl x509 -noout -enddate -in path/to/cert/file

This command gets the enddates of certificate files.

Typical output of this command is:

/usr/bin/find: '/etc/origin/node': No such file or directory
/usr/bin/find: '/etc/origin/master': No such file or directory
notAfter=May 25 16:39:40 2019 GMT
FileName= /etc/origin/node/cert.pem
unable to load certificate
139881193203616:error:0906D066:PEM routines:PEM_read_bio:bad end line:pem_lib.c:802:
unable to load certificate
140695459370912:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: TRUSTED CERTIFICATE
notAfter=May 25 16:39:40 2019 GMT
FileName= /etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem
notAfter=Dec  9 10:55:38 2017 GMT
FileName= /etc/pki/consumer/cert.pem
notAfter=Jan  1 04:59:59 2022 GMT
FileName= /etc/pki/entitlement/3343502840335059594.pem
notAfter=Aug 31 02:19:59 2017 GMT
FileName= /etc/pki/consumer/cert.pem
notAfter=Jan  1 04:59:59 2022 GMT
FileName= /etc/pki/entitlement/2387590574974617178.pem

Examples

>>> cert_enddate = shared[CertificatesEnddate]
>>> paths = cert_enddate.get_certificates_path
>>> paths[0]
'/etc/origin/node/cert.pem'
>>> cert_enddate.expiration_date(paths[0]).datetime
datetime(2019, 05, 25, 16, 39, 40)
>>> cert_enddate.expiration_date(paths[0]).str
'May 25 16:39:40 2019'
class insights.parsers.certificates_enddate.CertificatesEnddate(context, extra_bad_lines=[])[source]

Bases: insights.core.LegacyItemAccess, insights.core.CommandParser

Class to parse the expiration dates.

class ExpirationDate(str, datetime)

Bases: tuple

namedtuple: contains the expiration date in string and datetime format.

property datetime
property str
property certificates_path

Return filepaths in list or [].

Type

list

expiration_date(path)[source]

This will return a namedtuple([‘str’, ‘datetime’]) contains the expiration date in string and datetime format. If the expiration date is unparsable, the ExpirationDate.datetime should be None.

Parameters

path (str) -- The certificate file path.

Returns

A ExpirationDate for available path. None otherwise.

parse_content(content)[source]

Parse the content of crt files.