def handle_cis_response(session, response):
    """
    Handle the DigiCert CIS API response and any errors it might have experienced.
    :param response:
    :return:
    """
    if response.status_code == 404:
        raise Exception("DigiCert: order not in issued state")
    elif response.status_code == 406:
        log_header = copy.deepcopy(session.headers)
        log_header.pop("X-DC-DEVKEY")
        reset_cis_session(session)
        raise Exception("DigiCert: wrong header request format: " + str(log_header))
    elif response.status_code > 399:
        raise Exception("DigiCert rejected request with the error: " + response.text)
    if response.url.endswith("download"):
        return response.content
    else:
        return response.json()

    Handle the DigiCert CIS API response and any errors it might have experienced.
    :param response:
    :return:
    
lemur/plugins/lemur_digicert/plugin.py