Do not renew externally-signed CA as self-signed

Commit 49cf5ec64b fixed a bug that
prevented migration from externally-signed to self-signed IPA CA.
But it introduced a subtle new issue: certmonger-initiated renewal
renews an externally-signed IPA CA as a self-signed CA.

To resolve this issue, introduce the `--force-self-signed' flag for
the dogtag-ipa-ca-renew-agent script.  Add another certmonger CA
definition that calls this script with the `--force-self-signed'
flag.  Update dogtag-ipa-ca-renew-agent to only issue a self-signed
CA certificate if the existing certificate is self-signed or if
`--force-self-signed' was given.  Update `ipa-cacert-manage renew'
to supply `--force-self-signed' when appropriate.

As a result of these changes, certmonger-initiated renewal of an
externally-signed IPA CA certificate will not issue a self-signed
certificate.

Fixes: https://pagure.io/freeipa/issue/8176
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
Fraser Tweedale
2020-01-29 21:47:14 +11:00
parent 8e71605c54
commit 769180c2c6
7 changed files with 29 additions and 10 deletions
@@ -402,7 +402,7 @@ def retrieve_cert(**kwargs):
return result
def renew_ca_cert(reuse_existing, **kwargs):
def renew_ca_cert(reuse_existing, force_self_signed, **kwargs):
"""
This is used for automatic CA certificate renewal.
"""
@@ -420,7 +420,8 @@ def renew_ca_cert(reuse_existing, **kwargs):
if operation == 'SUBMIT':
state = 'retrieve'
if not reuse_existing and is_renewal_master():
if (is_self_signed or force_self_signed) \
and not reuse_existing and is_renewal_master():
state = 'request'
csr_file = paths.IPA_CA_CSR
@@ -473,7 +474,9 @@ def renew_ca_cert(reuse_existing, **kwargs):
def main():
kwargs = {
'reuse_existing': False,
'force_self_signed': False,
}
try:
sys.argv.remove('--reuse-existing')
except ValueError:
@@ -481,6 +484,13 @@ def main():
else:
kwargs['reuse_existing'] = True
try:
sys.argv.remove('--force-self-signed')
except ValueError:
pass
else:
kwargs['force_self_signed'] = True
operation = os.environ.get('CERTMONGER_OPERATION')
if operation not in ('SUBMIT', 'POLL'):
return OPERATION_NOT_SUPPORTED_BY_HELPER