Compare commits

...

2 commits

Author SHA1 Message Date
2892c30f69
Allow force on --issue-cert 2025-01-25 23:25:44 -03:00
9c1538de29
Allow custom ssl server 2025-01-25 23:01:38 -03:00

View file

@ -76,7 +76,14 @@ class Cloudflare:
dns_list = self.list_dns(zone_id, type_)
return dns_list['result'][0]['content']
def issue_cert(self, ssl_home: str, acme_directory: str, domains: List[str]) -> None:
def issue_cert(
self,
ssl_home: str,
acme_directory: str,
domains: List[str],
server: str = 'zerossl',
force: bool = False,
) -> None:
env = {
'HOME': ssl_home,
'CF_Key': self.key,
@ -84,7 +91,10 @@ class Cloudflare:
}
acme = os.path.join(script_dir, acme_directory, 'acme.sh')
kwargs = [acme, '--issue', '--dns', 'dns_cf', '-d', self.host]
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}"])
@ -169,8 +179,14 @@ class CloudflareAction(argparse.Action):
if option_string == '--issue-cert':
ssl_home = config.get('ssl', 'ssl_home')
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)
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(
@ -207,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()