MCPcopy Create free account
hub / github.com/mpdavis/python-jose / normalize_pem

Function normalize_pem

tests/algorithms/test_EC.py:65–79  ·  view source on GitHub ↗
(key_pem_str)

Source from the content-addressed store, hash-verified

63
64
65def 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
82def _backend_exception_types():

Callers 5

test_to_pemMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…