def create_proxy_credentials(issuer_cred, public_key, lifetime_hours):
    """
    Given an issuer credentials PEM file in the form of a string, a public_key
    string from an activation requirements document, and an int for the
    proxy lifetime, returns credentials as a unicode string in PEM format
    containing a new proxy certificate and an extended proxy chain.
    """
    # parse the issuer credential
    loaded_cert, loaded_private_key, issuer_chain = parse_issuer_cred(issuer_cred)

    # load the public_key into a cryptography object
    loaded_public_key = serialization.load_pem_public_key(
        public_key.encode("ascii"), backend=default_backend()
    )

    # check that the issuer certificate is not an old proxy
    # and is using the keyUsage section as required
    confirm_not_old_proxy(loaded_cert)
    validate_key_usage(loaded_cert)

    # create the proxy cert cryptography object
    new_cert = create_proxy_cert(
        loaded_cert, loaded_private_key, loaded_public_key, lifetime_hours
    )

    # extend the proxy chain as a unicode string
    extended_chain = loaded_cert.public_bytes(serialization.Encoding.PEM).decode(
        "ascii"
    ) + six.u(issuer_chain)

    # return in PEM format as a unicode string
    return (
        new_cert.public_bytes(serialization.Encoding.PEM).decode("ascii")
        + extended_chain
    )
Given an issuer credentials PEM file in the form of a string, a public_key
    string from an activation requirements document, and an int for the
    proxy lifetime, returns credentials as a unicode string in PEM format
    containing a new proxy certificate and an extended proxy chain.