Container platform | Public certificates | Private certificates |
---|---|---|
Windows container | C:\appservice\certificates\public |
C:\appservice\certificates\private |
Linux container | /var/ssl/certs |
/var/ssl/private |
# load OpenSSL.crypto
from OpenSSL import crypto
# open it, using password. Supply/read your own from stdin.
p12 = crypto.load_pkcs12(open("/var/ssl/private/6E619CF099EC156414E939B53358C98841234567.p12", "rb").read(), b"")
# get various properties of said file.
# note these are PyOpenSSL objects, not strings although you
# can convert them to PEM-encoded strings.
p12.get_certificate() # (signed) certificate object
p12.get_privatekey() # private key.
p12.get_ca_certificates() # ca chain.
from cryptography.hazmat.primitives.serialization import pkcs12
with open("/var/ssl/private/6E619CF099EC156414E939B53358C98841234567.p12", "rb") as f:
private_key, certificate, additional_certificates = pkcs12.load_key_and_certificates(f.read(), b"")
print(certificate.not_valid_after)
All done. Thanks for reading! I hope you have fun in it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.