Skip to content

Instantly share code, notes, and snippets.

@suzaku
Created December 24, 2018 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suzaku/01e29b1698d372c3c916405d9d502c15 to your computer and use it in GitHub Desktop.
Save suzaku/01e29b1698d372c3c916405d9d502c15 to your computer and use it in GitHub Desktop.
Parse notAfter of P12 certificate
import datetime
from OpenSSL.crypto import load_pkcs12
with open("your.p12", "rb") as f:
content = f.read()
p = load_pkcs12(content, "YOUR PASSSPHRASE")
cert = p.get_certificate()
format = "%Y%m%d%H%M%SZ"
print(datetime.datetime.strptime(cert.get_notAfter(), format))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment