crtmgr: fix bug if CERTMONGER_CERTIFICATE not set

If CERTMONGER_CERTIFICATE is not set in certain scenario, the
code would fail since None cannot be passed to loading certificates.

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

Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
Stanislav Laznicka 2017-08-16 15:34:35 +02:00 committed by Pavel Vomacka
parent 0412625a2b
commit a3c11b01af

View File

@ -379,10 +379,10 @@ def retrieve_or_reuse_cert(**kwargs):
if not nickname:
return (REJECTED, "Nickname could not be determined")
cert = x509.load_pem_x509_certificate(
fix_pem(os.environ.get('CERTMONGER_CERTIFICATE'))) # TODO: the fix_pem somehow got there early, so making this comment way too long to get rid of it later
cert = os.environ.get('CERTMONGER_CERTIFICATE')
if not cert:
return (REJECTED, "New certificate requests not supported")
cert = x509.load_pem_x509_certificate(fix_pem(cert.encode('ascii')))
with ldap_connect() as conn:
try: