Fix cert revocation when removing all certs via host/service-mod

When removing all host/service certificates via host/service-mod
--certificate=, the removed certificates should be revoked, but they
are not.  Examine whether the --certificate option was provided to
determine whether certs should be revoked, instead of looking for a
cert list in the options (which in this case is empty).

Fixes: https://fedorahosted.org/freeipa/ticket/6305
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Fraser Tweedale authored and Jan Cholasta committed 2016-09-23 08:10:11 +02:00
1 parent 71b3352ad0
commit 97d4ffc2dc
2 files changed
+4 -2

No files matched your search

+2 -1
View File
@@ -898,7 +898,8 @@ class host_mod(LDAPUpdate):
certs_der = [x509.normalize_certificate(c) for c in certs]
# revoke removed certificates
if certs and self.api.Command.ca_is_enabled()['result']:
ca_is_enabled = self.api.Command.ca_is_enabled()['result']
if 'usercertificate' in options and ca_is_enabled:
try:
entry_attrs_old = ldap.get_entry(dn, ['usercertificate'])
except errors.NotFound:
+2 -1
View File
@@ -701,7 +701,8 @@ class service_mod(LDAPUpdate):
certs = entry_attrs.get('usercertificate') or []
certs_der = [x509.normalize_certificate(c) for c in certs]
# revoke removed certificates
if certs and self.api.Command.ca_is_enabled()['result']:
ca_is_enabled = self.api.Command.ca_is_enabled()['result']
if 'usercertificate' in options and ca_is_enabled:
try:
entry_attrs_old = ldap.get_entry(dn, ['usercertificate'])
except errors.NotFound: