示例#1
0
def get_cis_certificate(session, base_url, order_id):
    """Retrieve certificate order id from Digicert API, including the chain"""
    certificate_url = "{0}/platform/cis/certificate/{1}/download".format(base_url, order_id)
    session.headers.update({"Accept": "application/x-pkcs7-certificates"})
    response = session.get(certificate_url)
    response_content = handle_cis_response(response)

    cert_chain_pem = convert_pkcs7_bytes_to_pem(response_content)
    if len(cert_chain_pem) < 3:
        raise Exception("Missing the certificate chain")
    return cert_chain_pem
示例#2
0
def test_convert_pkcs7_bytes_to_pem():
    from lemur.common.utils import convert_pkcs7_bytes_to_pem
    from lemur.common.utils import parse_certificate
    cert_chain = convert_pkcs7_bytes_to_pem(CERT_CHAIN_PKCS7_PEM)
    assert (len(cert_chain) == 3)

    leaf = cert_chain[1]
    root = cert_chain[2]

    assert (parse_certificate("\n".join(
        str(root).splitlines())) == ROOTCA_CERT)
    assert (parse_certificate("\n".join(
        str(leaf).splitlines())) == INTERMEDIATE_CERT)