From 00a7868fa4011a0639bf96d23225c4203980bfb3 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 16 Apr 2019 11:37:51 +0200 Subject: [PATCH] Reuse key type and size in certmonger resubmit Certmonger has hard-coded defaults for key size and key type. In case a request does not contain these values, certmonger uses 2048 RSA keys. Since the CA now has 3072, it will also rekey the CA to 2048 instead of resubmitting with the existing 2048 bit key. Use key-size and key-type from the existing request when resubmitting. Related: https://pagure.io/freeipa/issue/6790 Signed-off-by: Christian Heimes Reviewed-By: Alexander Bokovoy --- ipalib/install/certmonger.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ipalib/install/certmonger.py b/ipalib/install/certmonger.py index 7f8d70af7..f433ffa09 100644 --- a/ipalib/install/certmonger.py +++ b/ipalib/install/certmonger.py @@ -590,6 +590,18 @@ def resubmit_request( update['template-is-ca'] = True update['template-ca-path-length'] = -1 # no path length + # TODO: certmonger assumes some hard-coded defaults like RSA 2048. + # Try to fetch values from current cert rather. + for key, convert in [('key-size', int), ('key-type', str)]: + try: + value = request.prop_if.Get(DBUS_CM_REQUEST_IF, key) + except dbus.DBusException: + continue + else: + if value: + # convert dbus.Int64() to int, dbus.String() to str + update[key] = convert(value) + if len(update) > 0: request.obj_if.modify(update) request.obj_if.resubmit()