(key_pem_str)
| 63 | |
| 64 | |
| 65 | def normalize_pem(key_pem_str): |
| 66 | # Search for the PEM sections |
| 67 | pem_match = PEM_REGEX.search(key_pem_str) |
| 68 | if not pem_match: |
| 69 | raise ValueError("The provided string does not contain a valid PEM formatted data.") |
| 70 | |
| 71 | header = pem_match.group(1) |
| 72 | body = pem_match.group(2) |
| 73 | footer = pem_match.group(3) |
| 74 | |
| 75 | # Remove all newlines and spaces from the body |
| 76 | clean_body = WHITE_SPACE_REGEX.sub("", body) |
| 77 | |
| 78 | # Reassemble the PEM string |
| 79 | return f"{header}\n{clean_body}\n{footer}" |
| 80 | |
| 81 | |
| 82 | def _backend_exception_types(): |
no outgoing calls
no test coverage detected
searching dependent graphs…