def extract_cert_chain(pem_bytes: bytes) -> bytes:
    """Extract a certificate chain from a PEM file's bytes, removing line breaks.

    :param bytes pem_bytes: The PEM file's bytes
    :return: The certificate chain
    :rtype: bytes
    """

    # if index raises ValueError, there's no PEM-encoded cert
    start = pem_bytes.index(b"-----BEGIN CERTIFICATE-----")
    footer = b"-----END CERTIFICATE-----"
    end = pem_bytes.rindex(footer)
    chain = pem_bytes[start : end + len(footer) + 1]

    return b"".join(chain.splitlines())
Extract a certificate chain from a PEM file's bytes, removing line breaks.

    :param bytes pem_bytes: The PEM file's bytes
    :return: The certificate chain
    :rtype: bytes
    
Solutions/CyberArkAudit/Data Connectors/.python_packages/lib/site-packages/azure/identity/_credentials/certificate.py