INNER CODE UNIT · Python
get_pkcs12_serial
ahembree/ansible-hms-docker · roles/hmsdocker/files/scripts/traefik_cert_convert.py:111
def get_pkcs12_serial(data: bytes, passph: str=None) -> str:
"""Gets the serial from a PKCS12 file
Args:
data (``bytes``): The certificate file binary data
passph (``str``, optional): The files passphrase. Defaults to ``None``.
Returns:
``str``: The serial of the PKCS12 file
"""
logging.debug('Obtaining PKCS12 certificate serial number')
serial = pkcs12.load_pkcs12(data, passph).cert.certificate.serial_number
logging.debug(f'PKSC12 Serial: {serial}')
return serial
def get_pem_serial(certificate: str, private: bool=False, passphrase: str=None) -> str:
"""Gets the serial from PEM data