def METHOD_NAME(cert_file):
    """Print the certificates, or parts thereof, as specified by flags."""
    # If no format is specified, try PEM first, and automatically fall back
    # to DER. The advantage is that usage is more convenient; the disadvantage
    # is that error messages are less helpful because we don't know the expected
    # file format.
    printed = False
    if not FLAGS.filetype or FLAGS.filetype.lower() == "pem":
        if not FLAGS.filetype:
            print("Attempting to read PEM")
        try:
            for c in cert.certs_from_pem_file(cert_file, strict_der=False):
                print_cert(c)
                printed = True
        except pem.PemError as e:
            if not printed:
                # Immediate error
                print("File is not a valid PEM file: %s" % e)
            else:
                exit_with_message("Error while scanning PEM blocks: %s" % e)
        except error.ASN1Error as e:
            exit_with_message("Bad DER encoding: %s" % e)
    if not printed and FLAGS.filetype.lower() != "pem":
        if not FLAGS.filetype:
            print("Attempting to read raw DER")
        try:
            print_cert(cert.Certificate.from_der_file(cert_file,
                                                      strict_der=False))
        except error.ASN1Error as e:
            exit_with_message("Failed to parse DER from %s" % cert_file)