pub fn load_pkcs12<'py>(
py: Python<'py>,
data: &[u8],
password: Option<&[u8]>,
) -> PyResult<Bound<'py, PyTuple>>Expand description
Extract both certificates and private keys from a PKCS#12 archive.
Returns a 2-tuple (certs, keys) where:
certsis a :class:listof :class:Certificateobjects.keysis a :class:listof :class:bytes, each a DER-encoded PKCS#8OneAsymmetricKeystructure.
Encrypted bags are decrypted with password when the openssl
Cargo feature is enabled; without it, encrypted bags are silently
skipped and a :exc:ValueError is raised only on structural errors.
Pass b"" or omit password for password-less archives.
Use :func:load_pkcs12_certificates if you only need certificates, or
:func:load_pkcs12_keys if you only need keys.
data = open("archive.p12", "rb").read()
certs, keys = synta.load_pkcs12(data, b"s3cr3t")
for cert in certs:
print(cert.subject)
for key_der in keys:
from cryptography.hazmat.primitives.serialization import load_der_private_key
key = load_der_private_key(key_der, None)