Converts a given certificate or list to PEM format

def pem_to_der(cert, return_multiple=True):
    """ Converts a given certificate or list to PEM format"""

    # initialize the certificate array
    cert_list = []

    # If certificate is in DER then un-armour it
    if pem.detect(cert):
        for _, _, der_bytes in pem.unarmor(cert, multiple=True):
            cert_list.append(der_bytes)
    else:
        cert_list.append(cert)

    # return multiple if return_multiple is set else first element
    if return_multiple:
        return cert_list
    else:
        return cert_list.pop()