Fix ACME: Include apex domains when requesting certificates for subdomains

This commit is contained in:
Maurus Decimus
2026-05-07 15:40:23 +02:00
parent 410607c480
commit bc2b14f1f2
2 changed files with 7 additions and 4 deletions

View File

@@ -43,6 +43,8 @@ impl AcmeRequestBuilder {
} else {
let server_name = server.core.network.server_name.as_str();
let domain_suffix = format!(".{domain}");
let matches_zone =
|name: &str| name == domain || name.ends_with(&domain_suffix);
// Add technical domains
let mut domains = HOSTNAMES
@@ -50,15 +52,15 @@ impl AcmeRequestBuilder {
.map(|hostname| format!("{hostname}.{domain}"))
.collect::<BTreeSet<_>>();
// Add server name if it matches the domain
if server_name.ends_with(&domain_suffix) {
// Add server name if it matches the domain (including the apex itself)
if matches_zone(server_name) {
domains.insert(server_name.to_string());
}
// Add mail exchangers
for exchanger in &server.core.network.info.mxs {
if let Some(exchanger) = &exchanger.hostname
&& exchanger.ends_with(&domain_suffix)
&& matches_zone(exchanger)
{
domains.insert(exchanger.to_string());
}
@@ -67,7 +69,7 @@ impl AcmeRequestBuilder {
// Add service hosts
for (_, service) in &server.core.network.info.services {
if let Some(service) = &service.hostname
&& service.ends_with(&domain_suffix)
&& matches_zone(service)
{
domains.insert(service.to_string());
}