mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-08-02 04:44:42 +00:00
ipaclient_setup_nss: Fix undefined ca_certs for NoCertificateError case
In case get_certs_from_ldap failed with errors.NoCertificateError the code lead to a trace back as certstore.make_compat_ca_certs was using with undefined ca_certs variable. The code to generate ca_certs for this case was copied over from ipaclient_api. This is loading the certificate list from paths.IPA_CA_CRT.
This commit is contained in:
@@ -150,7 +150,8 @@ from ansible.module_utils.ansible_ipa_client import (
|
|||||||
get_certs_from_ldap, DN, certstore, x509, logger, certdb,
|
get_certs_from_ldap, DN, certstore, x509, logger, certdb,
|
||||||
CalledProcessError, tasks, client_dns, configure_certmonger, services,
|
CalledProcessError, tasks, client_dns, configure_certmonger, services,
|
||||||
update_ssh_keys, save_state, configure_ldap_conf, configure_nslcd_conf,
|
update_ssh_keys, save_state, configure_ldap_conf, configure_nslcd_conf,
|
||||||
configure_openldap_conf, hardcode_ldap_server, getargspec
|
configure_openldap_conf, hardcode_ldap_server, getargspec, NUM_VERSION,
|
||||||
|
serialization
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -271,6 +272,17 @@ def main():
|
|||||||
ca_subject = DN(('CN', 'Certificate Authority'), subject_base)
|
ca_subject = DN(('CN', 'Certificate Authority'), subject_base)
|
||||||
else:
|
else:
|
||||||
ca_subject = None
|
ca_subject = None
|
||||||
|
|
||||||
|
# Set ca_certs
|
||||||
|
# Copied from ipaclient_api
|
||||||
|
ca_certs = x509.load_certificate_list_from_file(paths.IPA_CA_CRT)
|
||||||
|
if 40500 <= NUM_VERSION < 40590:
|
||||||
|
ca_certs = [cert.public_bytes(serialization.Encoding.DER)
|
||||||
|
for cert in ca_certs]
|
||||||
|
elif NUM_VERSION < 40500:
|
||||||
|
ca_certs = [cert.der_data for cert in ca_certs]
|
||||||
|
# Copied from ipaclient_api
|
||||||
|
|
||||||
ca_certs = certstore.make_compat_ca_certs(ca_certs, cli_realm,
|
ca_certs = certstore.make_compat_ca_certs(ca_certs, cli_realm,
|
||||||
ca_subject)
|
ca_subject)
|
||||||
ca_certs_trust = [(c, n,
|
ca_certs_trust = [(c, n,
|
||||||
|
|||||||
Reference in New Issue
Block a user