From fb346fab2495a9343ed68131c0ebf071e3e9654f Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 9 Jul 2018 13:53:44 +0200 Subject: [PATCH] Wait for client certificates ipa-client-install --request-cert now waits until certmonger has provided a host certificate. In case of an error, ipa-client-install no longer pretents to success but fails with an error code. The --request-cert option also ensures that certmonger is enabled and running. See: Fixes: https://pagure.io/freeipa/issue/7623 Signed-off-by: Christian Heimes Reviewed-By: Stanislav Laznicka --- ipaclient/install/client.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/ipaclient/install/client.py b/ipaclient/install/client.py index 5173d90bfeb61acab6032f2972dcc4a0d1344094..0fbe31b762561b3e2ee2f35a666a93de8857bced 100644 --- a/ipaclient/install/client.py +++ b/ipaclient/install/client.py @@ -775,6 +775,7 @@ def configure_certmonger( cmonger = services.knownservices.certmonger try: cmonger.enable() + cmonger.start() except Exception as e: logger.error( "Failed to configure automatic startup of the %s daemon: %s", @@ -786,14 +787,24 @@ def configure_certmonger( subject = str(DN(('CN', hostname), subject_base)) passwd_fname = os.path.join(paths.IPA_NSSDB_DIR, 'pwdfile.txt') try: - certmonger.request_cert( + certmonger.request_and_wait_for_cert( certpath=paths.IPA_NSSDB_DIR, - nickname='Local IPA host', subject=subject, dns=[hostname], - principal=principal, passwd_fname=passwd_fname) - except Exception as ex: - logger.error( - "%s request for host certificate failed: %s", - cmonger.service_name, ex) + storage='NSSDB', + nickname='Local IPA host', + subject=subject, + dns=[hostname], + principal=principal, + passwd_fname=passwd_fname, + resubmit_timeout=120, + ) + except Exception as e: + logger.exception("certmonger request failed") + raise ScriptError( + "{} request for host certificate failed: {}".format( + cmonger.service_name, e + ), + rval=CLIENT_INSTALL_ERROR + ) def configure_sssd_conf( -- 2.17.1