From 2892c30f698761a7a37d92a23be4177f81dc4c2d Mon Sep 17 00:00:00 2001
From: Lain <lain@serialexperiments.club>
Date: Sat, 25 Jan 2025 23:25:44 -0300
Subject: [PATCH] Allow force on --issue-cert

---
 cloudflare.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/cloudflare.py b/cloudflare.py
index 94321ca..3c5191a 100755
--- a/cloudflare.py
+++ b/cloudflare.py
@@ -82,6 +82,7 @@ class Cloudflare:
         acme_directory: str,
         domains: List[str],
         server: str = 'zerossl',
+        force: bool = False,
 ) -> None:
         env = {
             'HOME': ssl_home,
@@ -92,6 +93,9 @@ class Cloudflare:
         acme = os.path.join(script_dir, acme_directory, 'acme.sh')
         kwargs = [acme, '--server', server, '--issue', '--dns', 'dns_cf', '-d', self.host]
 
+        if force:
+            kwargs.append('--force')
+
         for domain in domains:
             kwargs.extend(['-d', f"{domain}.{self.host}"])
 
@@ -177,7 +181,12 @@ class CloudflareAction(argparse.Action):
             acme_directory = config.get('ssl', 'acme_directory')
             server = config.get('ssl', 'server', fallback='zerossl')
             subdomains = config.get('General', 'subdomains').replace(' ', '').split(',')
-            self.cloudflare.issue_cert(ssl_home, acme_directory, subdomains, server)
+            force = False
+
+            if values == "force":
+                force = True
+
+            self.cloudflare.issue_cert(ssl_home, acme_directory, subdomains, server, force)
 
         if option_string == '--maintenance':
             self.cloudflare.update_dns(
@@ -214,6 +223,6 @@ if __name__ == '__main__':
     command_parser = argparse.ArgumentParser()
     command_parser.add_argument('--list-dns', action=CloudflareAction, nargs=1)
     command_parser.add_argument('--update-dns', action=CloudflareAction, nargs=0)
-    command_parser.add_argument('--issue-cert', action=CloudflareAction, nargs=0)
+    command_parser.add_argument('--issue-cert', action=CloudflareAction, nargs='?')
     command_parser.add_argument('--maintenance', action=CloudflareAction, nargs=0)
     command_parser.parse_args()