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-08-27 15:56:12 +02:00 committed by Tibor Dudlák
parent 31a92c1677
commit c29581c9a0
No known key found for this signature in database
GPG Key ID: 12B8BD343576CDF5

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