add strip_cert_header() to tasks.py

https://pagure.io/freeipa/issue/7687

Reviewed-By: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Tibor Dudlak <tdudlak@redhat.com>
This commit is contained in:
Michal Reznik
2018-09-06 13:49:34 +02:00
committed by Tibor Dudlák
parent 31a92c1677
commit c29581c9a0
+13
View File
@@ -1531,3 +1531,16 @@ def generate_ssh_keypair():
return (private_key_str, public_key_str)
def strip_cert_header(pem):
"""
Remove the header and footer from a certificate.
"""
regexp = (
r"^-----BEGIN CERTIFICATE-----(.*?)-----END CERTIFICATE-----"
)
s = re.search(regexp, pem, re.MULTILINE | re.DOTALL)
if s is not None:
return s.group(1)
else:
return pem