From b7babf6e7c3fa12bff9bd067091e2a4d7fc1de32 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 11 Jun 2018 23:15:23 +0200 Subject: [PATCH] use tldextract to splitout only subdomain --- authenticator.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/authenticator.py b/authenticator.py index d40dec2..b1bb30d 100755 --- a/authenticator.py +++ b/authenticator.py @@ -10,6 +10,7 @@ import urlparse import configparser import sys import logging +import tldextract def setup_logger(): @@ -85,7 +86,10 @@ def set_record(token, host, zone, logger): headers = {"Authorization": "Bearer %s" % (token)} try: - certbot_domain = "_acme-challenge.%s" % (os.environ['CERTBOT_DOMAIN']) + custom_cache_extract = tldextract.TLDExtract( + cache_file=os.path.join(os.path.expanduser("~"), "tld_set")) + domain = custom_cache_extract(os.environ['CERTBOT_DOMAIN']) + certbot_domain = "_acme-challenge.%s" % (domain.subdomain) certbot_validation = os.environ['CERTBOT_VALIDATION'] except KeyError, e: logger.error("Environment Variable %s not set" % (e)) @@ -133,8 +137,6 @@ def main(): # add txt record z_record = set_record(auth_token, config["API_HOST"], zone_name, logger) - print z_record - if __name__ == "__main__": main()