INNER CODE UNIT · Python
get_pem_serial
ahembree/ansible-hms-docker · roles/hmsdocker/files/scripts/traefik_cert_convert.py:126
def get_pem_serial(certificate: str, private: bool=False, passphrase: str=None) -> str:
"""Gets the serial from PEM data
Args:
certificate (``str``): The certificate data in PEM format
private (``bool``, optional): Whether it's a private key or not. Defaults to ``False``.
passphrase (``bool``, optional): The private keys passphrase. Defaults to ``None``.
Returns:
``str``: The serial of the PEM data
"""
logging.debug(f'Obtaining PEM certificate serial number')
serial = x509.load_pem_x509_certificate(str.encode(certificate)).serial_number
logging.debug(f'PEM Serial: {serial}')
return serial
def get_traefik_cert_store(path: str) -> dict:
"""Gets the Traefik certificate store data