mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 11:44:38 +03:00
admin: better handling of disabled mta-sts during self-check
if admin has disabled mta-sts for a domain, we still check for records & policies, but won't mark it as error when they don't exist. we do now keep warning that mta-sts isn't enabled, otherwise we would start showing a green "ok". this also fixes the mta-sts code returning ErrNoPolicy when mtasts.<domain> doesn't exist. the dns lookup is done with the reguler "net" package dns lookup code, not through adns, so we look for two types of DNSError's. noticed a while ago when testing with MTA-STS while debugging TLS connection issues with MS.
This commit is contained in:
@ -1281,8 +1281,13 @@ Ensure a DNS TXT record like the following exists:
|
||||
defer logPanic(ctx)
|
||||
defer wg.Done()
|
||||
|
||||
// The admin has explicitly disabled mta-sts, keep warning about it.
|
||||
if domConf.MTASTS == nil {
|
||||
addf(&r.MTASTS.Warnings, "MTA-STS is not configured for this domain.")
|
||||
}
|
||||
|
||||
record, txt, err := mtasts.LookupRecord(ctx, log.Logger, resolver, domain)
|
||||
if err != nil {
|
||||
if err != nil && !(domConf.MTASTS == nil && errors.Is(err, mtasts.ErrNoRecord)) {
|
||||
addf(&r.MTASTS.Errors, "Looking up MTA-STS record: %s", err)
|
||||
}
|
||||
r.MTASTS.TXT = txt
|
||||
@ -1292,7 +1297,9 @@ Ensure a DNS TXT record like the following exists:
|
||||
|
||||
policy, text, err := mtasts.FetchPolicy(ctx, log.Logger, domain)
|
||||
if err != nil {
|
||||
addf(&r.MTASTS.Errors, "Fetching MTA-STS policy: %s", err)
|
||||
if !(domConf.MTASTS == nil && errors.Is(err, mtasts.ErrNoPolicy)) {
|
||||
addf(&r.MTASTS.Errors, "Fetching MTA-STS policy: %s", err)
|
||||
}
|
||||
} else if policy.Mode == mtasts.ModeNone {
|
||||
addf(&r.MTASTS.Warnings, "MTA-STS policy is present, but does not require TLS.")
|
||||
} else if policy.Mode == mtasts.ModeTesting {
|
||||
|
Reference in New Issue
Block a user