Before I found the --keep-until-expiring
option in the Let’s Encrypt command line client, I was thinking I’d have to parse the cert, extract the expiry date, then check it against the current date before returning True or False.
Thankfully I found the much easier option, but I decided to post the code I wrote to read the date just in case I need something like it in the future.
[python]
from datetime import datetime
from OpenSSL import crypto as c
cert = c.load_certificate(c.FILETYPE_PEM, file(‘/etc/letsencrypt/live/<domain>/cert.pem’).read())
datetime.strptime(cert.get_notAfter(),”%Y%m%d%H%M%SZ”)
[/python]
#1 by Thomas on July 13, 2016 - 7:57 pm
Thanks a lot ! 🙂
#2 by Denis on July 28, 2017 - 5:47 am
Thank you very much !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#3 by Luis on October 3, 2019 - 1:52 pm
yep, this is exactly what i was looking for. thanks!