mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Handle missing LWCA certificate or chain
If lightweight CA key replication has not completed, requests for the certificate or chain will return 404**. This can occur in normal operation, and should be a temporary condition. Detect this case and handle it by simply omitting the 'certificate' and/or 'certificate_out' fields in the response, and add a warning message to the response. Also update the client-side plugin that handles the --certificate-out option. Because the CLI will automatically print the warning message, if the expected field is missing from the response, just ignore it and continue processing. ** after the Dogtag NullPointerException gets fixed! Part of: https://pagure.io/freeipa/issue/7964 Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
This commit is contained in:
@@ -33,13 +33,24 @@ class WithCertOutArgs(MethodOverride):
|
||||
error=str(e))
|
||||
|
||||
result = super(WithCertOutArgs, self).forward(*keys, **options)
|
||||
|
||||
if filename:
|
||||
# if result certificate / certificate_chain not present in result,
|
||||
# it means Dogtag did not provide it (probably due to LWCA key
|
||||
# replication lag or failure. The server transmits a warning
|
||||
# message in this case, which the client automatically prints.
|
||||
# So in this section we just ignore it and move on.
|
||||
certs = None
|
||||
if options.get('chain', False):
|
||||
certs = result['result']['certificate_chain']
|
||||
if 'certificate_chain' in result['result']:
|
||||
certs = result['result']['certificate_chain']
|
||||
else:
|
||||
certs = [base64.b64decode(result['result']['certificate'])]
|
||||
certs = (x509.load_der_x509_certificate(cert) for cert in certs)
|
||||
x509.write_certificate_list(certs, filename)
|
||||
if 'certificate' in result['result']:
|
||||
certs = [base64.b64decode(result['result']['certificate'])]
|
||||
if certs:
|
||||
x509.write_certificate_list(
|
||||
(x509.load_der_x509_certificate(cert) for cert in certs),
|
||||
filename)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user