From 57764d0cf5675abe5331b670ec5baeefed00960c Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 6 Jan 2024 18:21:25 +0000 Subject: [PATCH] dns: require www. subdomain and request TLS certificate for it --- cmdeploy/src/cmdeploy/__init__.py | 5 ++++- cmdeploy/src/cmdeploy/dns.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmdeploy/src/cmdeploy/__init__.py b/cmdeploy/src/cmdeploy/__init__.py index d2f27f30..4edb2efa 100644 --- a/cmdeploy/src/cmdeploy/__init__.py +++ b/cmdeploy/src/cmdeploy/__init__.py @@ -424,7 +424,10 @@ def deploy_chatmail(config_path: Path) -> None: ) # Deploy acmetool to have TLS certificates. - deploy_acmetool(nginx_hook=True, domains=[mail_domain, f"mta-sts.{mail_domain}"]) + deploy_acmetool( + nginx_hook=True, + domains=[mail_domain, f"mta-sts.{mail_domain}", f"www.{mail_domain}"], + ) apt.packages( name="Install Postfix", diff --git a/cmdeploy/src/cmdeploy/dns.py b/cmdeploy/src/cmdeploy/dns.py index 60d78f55..e8e740a8 100644 --- a/cmdeploy/src/cmdeploy/dns.py +++ b/cmdeploy/src/cmdeploy/dns.py @@ -183,11 +183,14 @@ def check_necessary_dns(out, mail_domain): ipv4 = dns.get("A", mail_domain) ipv6 = dns.get("AAAA", mail_domain) mta_entry = dns.get("CNAME", "mta-sts." + mail_domain) + www_entry = dns.get("CNAME", "www." + mail_domain) to_print = [] if not (ipv4 or ipv6): to_print.append(f"\t{mail_domain}.\t\t\tA") if mta_entry != mail_domain + ".": to_print.append(f"\tmta-sts.{mail_domain}.\tCNAME\t{mail_domain}.") + if www_entry != mail_domain + ".": + to_print.append(f"\twww.{mail_domain}.\tCNAME\t{mail_domain}.") if to_print: to_print.insert( 0,