Skip to content

Commit

Permalink
fixup! feat!: single default ACME certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidePrincipi committed Feb 7, 2025
1 parent b80d9cf commit 3b2ea1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions imageroot/actions/delete-certificate/20writeconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import json
import sys
import os
import cert_helpers
import agent

def main():
request = json.load(sys.stdin)
Expand Down
6 changes: 4 additions & 2 deletions imageroot/pypkg/cert_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ def remove_custom_cert(name):
os.unlink(path)
except FileNotFoundError:
pass
rdb = agent.redis_connect(privileged=True)
rdb.delete(f'module/{os.environ["MODULE_ID"]}/certificate/{name}')

def has_acmejson_name(name):
"""Return True if name is found among acme.json Certificates."""
with open('acme/acme.json', 'r') as fp:
acmejson = json.load(fp)
for ocert in acmejson['acmeServer']["Certificates"]:
for ocert in acmejson['acmeServer']["Certificates"] or []:
if ocert["domain"]["main"] == name or name in ocert["domain"].get("sans", []):
return True
return False
Expand All @@ -62,7 +64,7 @@ def has_acmejson_cert(main, sans=[]):
acme.json Certificates."""
with open('acme/acme.json', 'r') as fp:
acmejson = json.load(fp)
for ocert in acmejson['acmeServer']["Certificates"]:
for ocert in acmejson['acmeServer']["Certificates"] or []:
if ocert["domain"]["main"] == main and set(ocert["domain"].get("sans", [])) == set(sans):
return True
return False
Expand Down

0 comments on commit 3b2ea1c

Please sign in to comment.