Skip to content

Commit

Permalink
inventory: add ACME certificate count and status
Browse files Browse the repository at this point in the history
  • Loading branch information
stephdl committed Sep 24, 2024
1 parent 40a0042 commit 8d0117e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/nethsec/inventory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,25 @@ def fact_custom_certificates(uci: EUci):
pass
return ret

def fact_acme_certificates(uci: EUci):
ret = {
'count': 0,
'issued': 0,
'pending': 0,
}
requested_certificates = utils.get_all_by_type(uci, 'acme', 'cert')
enabled_certificates = [certificate for certificate in requested_certificates
if requested_certificates[certificate]['enabled'] == '1']
for certificate in enabled_certificates:
ret['count'] += 1
domain = requested_certificates[certificate]['domains'][0]
cert_path = f'/etc/ssl/acme/{domain}.fullchain.crt'
if os.path.isfile(cert_path):
ret['issued'] += 1
else:
ret['pending'] += 1
return ret

def fact_subscription_status(uci: EUci):
return { 'status': uci.get('ns-plug', 'config', 'type', default='no') }

Expand Down

0 comments on commit 8d0117e

Please sign in to comment.