Merge pull request #1763 from YunoHost/fix-dns-suffix-during-xmpp-cert-setup

Fix DNS suffix edge case during XMPP certificate setup
This commit is contained in:
Alexandre Aubin 2024-01-13 19:30:40 +01:00 committed by GitHub
commit 491588bb88
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(