mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Extract ca_renewal cert update subroutine
When the CA renewal master renews certificates that are shared across CA replicas, it puts them in LDAP for the other CA replicas to see. The code to create/update these entries lives in the dogtag-ipa-ca-renew-agent renewal helper, but it will be useful for the ipa-cert-fix program too. Extract it to a subroutine in the cainstance module. Part of: https://pagure.io/freeipa/issue/7885 Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
@@ -270,23 +270,9 @@ def store_cert(**kwargs):
|
||||
return (REJECTED, "New certificate requests not supported")
|
||||
cert = x509.load_pem_x509_certificate(cert.encode('ascii'))
|
||||
|
||||
dn = DN(('cn', nickname), ('cn', 'ca_renewal'),
|
||||
('cn', 'ipa'), ('cn', 'etc'), api.env.basedn)
|
||||
try:
|
||||
with ldap_connect() as conn:
|
||||
try:
|
||||
entry = conn.get_entry(dn, ['usercertificate'])
|
||||
entry['usercertificate'] = [cert]
|
||||
conn.update_entry(entry)
|
||||
except errors.NotFound:
|
||||
entry = conn.make_entry(
|
||||
dn,
|
||||
objectclass=['top', 'pkiuser', 'nscontainer'],
|
||||
cn=[nickname],
|
||||
usercertificate=[cert])
|
||||
conn.add_entry(entry)
|
||||
except errors.EmptyModlist:
|
||||
pass
|
||||
cainstance.update_ca_renewal_entry(conn, nickname, cert)
|
||||
except Exception as e:
|
||||
attempts += 1
|
||||
if attempts < 10:
|
||||
|
||||
Reference in New Issue
Block a user