diff --git a/OTcerts.py b/OTcerts.py index 271efd9..945ef35 100644 --- a/OTcerts.py +++ b/OTcerts.py @@ -161,7 +161,7 @@ def get_alias_list(config, dns_conn, query, aliases): return result_list -def acme_request(config, domain_name, acme_test='DNS-01', dryrun=False, domains_list=None): +def acme_request(config, domain_name, acme_test='DNS-01', webroot=None, dryrun=False, domains_list=None): args = config['certbot']['base_args'] args += " -m {} ".format(config['certbot']['email']) @@ -178,7 +178,11 @@ def acme_request(config, domain_name, acme_test='DNS-01', dryrun=False, domains_ elif acme_test == 'HTTP-01': args += " --webroot certonly " args += "--preferred-challenges http-01 " - args += "-w {}/{}/htdocs ".format(config['apache']['webroot'], domain_name) + if webroot is None: + args += "-w {}/{}/htdocs ".format(config['apache']['webroot'], domain_name) + else: + args += "-w {} ".format(webroot) + if domains_list is None: args += "-d {}".format(domain_name) else: @@ -246,7 +250,8 @@ if __name__ == '__main__': alias_list = get_alias_list(config, dns_conn, mbox_query, server_addresses) # Per usi futuri, aggiungo l'alias 'mail.indivia.net' alias_list.append('mail.indivia.net') - if acme_request(config, vhost_name, acme_test='HTTP-01', dryrun=dryrun, domains_list=alias_list): + if acme_request(config, vhost_name, acme_test='HTTP-01', webroot=config['mail']['mbox_webroot'].strip(), + dryrun=dryrun, domains_list=alias_list): # non e' richiesto il link, punto direttamente le configurazioni alle dir di letsencrypt # link_cert(config, vhost_name, vhost_name, dryrun=dryrun) pass @@ -261,7 +266,8 @@ if __name__ == '__main__': smtp_fmt = ','.join(['%s'] * len(server_addresses)) smtp_query = smtp_list_stmt.format(smtp_fmt) alias_list = get_alias_list(config, dns_conn, smtp_query, server_addresses) - if acme_request(config, vhost_name, acme_test='HTTP-01', dryrun=dryrun, domains_list=alias_list): + if acme_request(config, vhost_name, acme_test='HTTP-01', webroot=config['mail']['smtp_webroot'].strip(), + dryrun=dryrun, domains_list=alias_list): # non e' richiesto il link, punto direttamente le configurazioni alle dir di letsencrypt # link_cert(config, vhost_name, vhost_name, dryrun=dryrun) pass