Fix DNS suffix edge case during XMPP certificate setup

This commit is contained in:
Alexandre Aubin 2024-01-12 22:00:10 +01:00 committed by GitHub
parent f53d09c3a2
commit 699500dbb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -577,9 +577,16 @@ def _prepare_certificate_signing_request(domain, key_file, output_folder):
or {}
)
sanlist = []
# Handle the boring case where the domain is not the root of the dns zone etc...
from yunohost.dns import _get_relative_name_for_dns_zone, _get_dns_zone_for_domain
base_dns_zone = _get_dns_zone_for_domain(domain)
basename = _get_relative_name_for_dns_zone(domain, base_dns_zone)
suffix = f".{basename}" if basename != "@" else ""
for sub in ("xmpp-upload", "muc"):
subdomain = sub + "." + domain
if xmpp_records.get("CNAME:" + sub) == "OK":
if xmpp_records.get("CNAME:" + sub + suffix) == "OK":
sanlist.append(("DNS:" + subdomain))
else:
logger.warning(