def cleanup_x509_text(txt): kts = txt.split(b'\n') kt = [b' ' + x for x in kts if len(x) and not (x.startswith(b'----') and x.endswith(b'----'))] return bytes_to_native_str(b' ' + b'\n '.join(kt) + b'\n')