[GH-ISSUE #3388] Issue with get_authoritative_server Function Failing for DKIM Check #1845

Closed
opened 2026-02-27 11:19:26 +03:00 by kerem · 6 comments
Owner

Originally created by @jerems6 on GitHub (Dec 22, 2024).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/3388

Impacted versions

  • OS Type: Ubuntu
  • OS Version: 24.04
  • Database Type: PostgreSQL
  • Database version: 16.6
  • Modoboa: 2.3.4
  • Installer used: Yes
  • Webserver: Nginx

Steps to reproduce

  1. Install modoboa using installer
  2. Add a domain, with DKIM enabled, default Key selector (modoboa) and Key length 2048
  3. Generate DKIM key via the command libe /srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py modo manage_dkim_keys ("generate key" was not available via the web UI after the fresh installation)
  4. Add TXT record on the DNS server: modoboa._domainkey.mydomain.com (v=DKIM1;k=rsa;p=XXXXX)
  5. Wait up to 48 hours
  6. Run the command the check the DKIM: /srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py modo check_mx

Current behavior

DKIM status showes "No record found"

Expected behavior

DKIM status shows record found

Proposed Fix

The get_authoritative_server function in Modoboa fails to retrieve the authoritative server during a DKIM check. The issue arises when querying with the domain like "modoboa._domainkey.mydomain.com". An exception is raised with "_domainkey.mydomain.com" of type dns.resolver.NXDOMAIN.

The function should handle dns.resolver.NXDOMAIN exceptions in addition to dns.resolver.NoAnswer, ensuring the logic continues with the domain's parent in such cases.

The issue occurs because dns.resolver.NXDOMAIN is not caught by the except block. This leads to the function halting prematurely instead of continuing to the parent domain.

github.com/modoboa/modoboa@2cb6ccebfa/modoboa/admin/lib.py (L208)

The except block should also handle dns.resolver.NXDOMAIN to ensure the function works correctly.

New line suggested:
except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN) as e:

Originally created by @jerems6 on GitHub (Dec 22, 2024). Original GitHub issue: https://github.com/modoboa/modoboa/issues/3388 # Impacted versions * OS Type: Ubuntu * OS Version: 24.04 * Database Type: PostgreSQL * Database version: 16.6 * Modoboa: 2.3.4 * Installer used: Yes * Webserver: Nginx # Steps to reproduce 1. Install modoboa using installer 2. Add a domain, with DKIM enabled, default Key selector (modoboa) and Key length 2048 3. Generate DKIM key via the command libe `/srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py modo manage_dkim_keys` ("generate key" was not available via the web UI after the fresh installation) 4. Add TXT record on the DNS server: modoboa._domainkey.mydomain.com (v=DKIM1;k=rsa;p=XXXXX) 5. Wait up to 48 hours 6. Run the command the check the DKIM: `/srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py modo check_mx` # Current behavior DKIM status showes "No record found" # Expected behavior DKIM status shows record found # Proposed Fix The `get_authoritative_server` function in Modoboa fails to retrieve the authoritative server during a DKIM check. The issue arises when querying with the domain like "modoboa._domainkey.mydomain.com". An exception is raised with "_domainkey.mydomain.com" of type dns.resolver.NXDOMAIN. The function should handle dns.resolver.NXDOMAIN exceptions in addition to dns.resolver.NoAnswer, ensuring the logic continues with the domain's parent in such cases. The issue occurs because dns.resolver.NXDOMAIN is not caught by the except block. This leads to the function halting prematurely instead of continuing to the parent domain. https://github.com/modoboa/modoboa/blob/2cb6ccebfa0224ef8a3e392ac130e637edf9e4b3/modoboa/admin/lib.py#L208 The except block should also handle dns.resolver.NXDOMAIN to ensure the function works correctly. New line suggested: `except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN) as e:`
kerem 2026-02-27 11:19:26 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@tonioo commented on GitHub (Jan 16, 2025):

Why does the resolution fail if you properly declared your record?

<!-- gh-comment-id:2595052918 --> @tonioo commented on GitHub (Jan 16, 2025): Why does the resolution fail if you properly declared your record?
Author
Owner

@Spitfireap commented on GitHub (Jan 16, 2025):

Perhaps @arthru if you could enlight us with your DNS knowledge ? :D

<!-- gh-comment-id:2595222394 --> @Spitfireap commented on GitHub (Jan 16, 2025): Perhaps @arthru if you could enlight us with your DNS knowledge ? :D
Author
Owner

@arthru commented on GitHub (Jan 16, 2025):

NXDOMAIN happens when a name could not be resolved

it can happen when asking a NS record for "modoboa._domainkey.mydomain.com"

based on reading this issue, the proposed fix looks good to me, but I did not test it myself

<!-- gh-comment-id:2595779468 --> @arthru commented on GitHub (Jan 16, 2025): NXDOMAIN happens when a name could not be resolved it can happen when asking a NS record for "modoboa._domainkey.mydomain.com" based on reading this issue, the proposed fix looks good to me, but I did not test it myself
Author
Owner

@Spitfireap commented on GitHub (Jan 16, 2025):

Thanks @arthru.

@jerems6 are you able to open a PR ?

<!-- gh-comment-id:2596419315 --> @Spitfireap commented on GitHub (Jan 16, 2025): Thanks @arthru. @jerems6 are you able to open a PR ?
Author
Owner

@stale[bot] commented on GitHub (Apr 25, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

<!-- gh-comment-id:2829161830 --> @stale[bot] commented on GitHub (Apr 25, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Author
Owner

@stovesy commented on GitHub (Jun 16, 2025):

The above changed fixed the issue I was having...

<!-- gh-comment-id:2976589167 --> @stovesy commented on GitHub (Jun 16, 2025): The above changed fixed the issue I was having...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#1845
No description provided.