public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[ACME] Skip autodiscover/mta-sts subdomains covered by wildcard certificates
127fb1e8
data/Dockerfiles/acme/acme.sh | 23 ++++++++++++++++++-----
data/Dockerfiles/acme/functions.sh | 22 ++++++++++++++++++++++
2 files changed, 40 insertions(+), 5 deletions(-)
Diff
diff --git a/data/Dockerfiles/acme/acme.sh b/data/Dockerfiles/acme/acme.sh
index ef510146..6472688a 100755
--- a/data/Dockerfiles/acme/acme.sh
+++ b/data/Dockerfiles/acme/acme.sh
@@ -253,10 +253,20 @@ while true; do
unset VALIDATED_CONFIG_DOMAINS_SUBDOMAINS
declare -a VALIDATED_CONFIG_DOMAINS_SUBDOMAINS
for SUBDOMAIN in "${ADDITIONAL_WC_ARR[@]}"; do
- if [[ "${SUBDOMAIN}.${SQL_DOMAIN}" != "${MAILCOW_HOSTNAME}" ]]; then
- if check_domain "${SUBDOMAIN}.${SQL_DOMAIN}"; then
- VALIDATED_CONFIG_DOMAINS_SUBDOMAINS+=("${SUBDOMAIN}.${SQL_DOMAIN}")
- fi
+ FULL_SUBDOMAIN="${SUBDOMAIN}.${SQL_DOMAIN}"
+
+ # Skip if subdomain matches MAILCOW_HOSTNAME
+ if [[ "${FULL_SUBDOMAIN}" == "${MAILCOW_HOSTNAME}" ]]; then
+ continue
+ fi
+ # Skip if subdomain is covered by a wildcard in ADDITIONAL_SAN
+ if is_covered_by_wildcard "${FULL_SUBDOMAIN}"; then
+ log_f "Subdomain '${FULL_SUBDOMAIN}' is covered by wildcard - skipping explicit subdomain"
+ continue
+ fi
+ # Validate and add subdomain
+ if check_domain "${FULL_SUBDOMAIN}"; then
+ VALIDATED_CONFIG_DOMAINS_SUBDOMAINS+=("${FULL_SUBDOMAIN}")
fi
done
VALIDATED_CONFIG_DOMAINS+=("${VALIDATED_CONFIG_DOMAINS_SUBDOMAINS[*]}")
@@ -273,7 +283,10 @@ while true; do
fi
# Only add mta-sts subdomain for alias domains
if [[ "mta-sts.${alias_domain}" != "${MAILCOW_HOSTNAME}" ]]; then
- if check_domain "mta-sts.${alias_domain}"; then
+ # Skip if mta-sts subdomain is covered by a wildcard
+ if is_covered_by_wildcard "mta-sts.${alias_domain}"; then
+ log_f "Alias domain mta-sts subdomain 'mta-sts.${alias_domain}' is covered by wildcard - skipping"
+ elif check_domain "mta-sts.${alias_domain}"; then
VALIDATED_CONFIG_DOMAINS+=("mta-sts.${alias_domain}")
fi
fi
diff --git a/data/Dockerfiles/acme/functions.sh b/data/Dockerfiles/acme/functions.sh
index 9db83291..bc4691ec 100644
--- a/data/Dockerfiles/acme/functions.sh
+++ b/data/Dockerfiles/acme/functions.sh
@@ -135,3 +135,25 @@ verify_challenge_path(){
return 1
fi
}
+
+# Check if a domain is covered by a wildcard in ADDITIONAL_SAN
+# Usage: is_covered_by_wildcard "subdomain.example.com"
+# Returns: 0 if covered, 1 if not covered
+is_covered_by_wildcard() {
+ local DOMAIN=$1
+
+ # Return early if no ADDITIONAL_SAN is set
+ if [[ -z ${ADDITIONAL_SAN} ]]; then
+ return 1
+ fi
+
+ # Extract parent domain (e.g., mail.example.com -> example.com)
+ local PARENT_DOMAIN=$(echo ${DOMAIN} | cut -d. -f2-)
+
+ # Check if ADDITIONAL_SAN contains a wildcard for this parent domain
+ if [[ "${ADDITIONAL_SAN}" == *"*.${PARENT_DOMAIN}"* ]]; then
+ return 0 # Covered by wildcard
+ fi
+
+ return 1 # Not covered
+}