From 9f150c4c352c5fff9956e120b7090d44fde250bf Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 Jun 2018 14:24:15 +0530 Subject: [PATCH] check for wildcard character in domain if not exists prepend it --- bench/config/lets_encrypt.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index c0361dc7..18525e7b 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -119,12 +119,22 @@ def renew_certs(): def setup_wildcard_ssl(domain, email, bench_path): - get_certbot() + + def _get_domain_name(domain): + if domain.split('.')[0] != '*': + domain = '*.{0}'.foramt(domain) + return domain + + domain = _get_domain_name(domain) + + return if not get_config(bench_path).get("dns_multitenant"): print("You cannot setup SSL without DNS Multitenancy") return + get_certbot() + email_param = '' if email: email_param = '--email {0}'.format(email) @@ -132,7 +142,7 @@ def setup_wildcard_ssl(domain, email, bench_path): try: exec_cmd("{path} certonly --manual --preferred-challenges=dns {email_param} \ --server https://acme-v02.api.letsencrypt.org/directory \ - --agree-tos -d *.{domain}".format(path=get_certbot_path(), domain=domain, + --agree-tos -d {domain}".format(path=get_certbot_path(), domain=domain, email_param=email_param)) except CommandFailedError: