mirror of
https://github.com/mjl-/mox.git
synced 2025-07-14 04:54:39 +03:00
implement outgoing tls reports
we were already accepting, processing and displaying incoming tls reports. now we start tracking TLS connection and security-policy-related errors for outgoing message deliveries as well. we send reports once a day, to the reporting addresses specified in TLSRPT records (rua) of a policy domain. these reports are about MTA-STS policies and/or DANE policies, and about STARTTLS-related failures. sending reports is enabled by default, but can be disabled through setting NoOutgoingTLSReports in mox.conf. only at the end of the implementation process came the realization that the TLSRPT policy domain for DANE (MX) hosts are separate from the TLSRPT policy for the recipient domain, and that MTA-STS and DANE TLS/policy results are typically delivered in separate reports. so MX hosts need their own TLSRPT policies. config for the per-host TLSRPT policy should be added to mox.conf for existing installs, in field HostTLSRPT. it is automatically configured by quickstart for new installs. with a HostTLSRPT config, the "dns records" and "dns check" admin pages now suggest the per-host TLSRPT record. by creating that record, you're requesting TLS reports about your MX host. gathering all the TLS/policy results is somewhat tricky. the tentacles go throughout the code. the positive result is that the TLS/policy-related code had to be cleaned up a bit. for example, the smtpclient TLS modes now reflect reality better, with independent settings about whether PKIX and/or DANE verification has to be done, and/or whether verification errors have to be ignored (e.g. for tls-required: no header). also, cached mtasts policies of mode "none" are now cleaned up once the MTA-STS DNS record goes away.
This commit is contained in:
@ -266,14 +266,16 @@ func GatherIPs(ctx context.Context, log *mlog.Log, resolver dns.Resolver, host d
|
||||
// Only usable records are returned. If any record was found, DANE is required and
|
||||
// this is indicated with daneRequired. If no usable records remain, the caller
|
||||
// must do TLS, but not verify the remote TLS certificate.
|
||||
//
|
||||
// Returned values are always meaningful, also when an error was returned.
|
||||
func GatherTLSA(ctx context.Context, log *mlog.Log, resolver dns.Resolver, host dns.Domain, expandedAuthentic bool, expandedHost dns.Domain) (daneRequired bool, daneRecords []adns.TLSA, tlsaBaseDomain dns.Domain, err error) {
|
||||
// ../rfc/7672:912
|
||||
// This function is only called when the lookup of host was authentic.
|
||||
|
||||
var l []adns.TLSA
|
||||
|
||||
tlsaBaseDomain = host
|
||||
if host == expandedHost || !expandedAuthentic {
|
||||
tlsaBaseDomain = host
|
||||
l, err = lookupTLSACNAME(ctx, log, resolver, 25, "tcp", host)
|
||||
} else if expandedAuthentic {
|
||||
// ../rfc/7672:934
|
||||
@ -286,8 +288,8 @@ func GatherTLSA(ctx context.Context, log *mlog.Log, resolver dns.Resolver, host
|
||||
}
|
||||
if len(l) == 0 || err != nil {
|
||||
daneRequired = err != nil
|
||||
log.Debugx("gathering tlsa records failed", err, mlog.Field("danerequired", daneRequired))
|
||||
return daneRequired, nil, dns.Domain{}, err
|
||||
log.Debugx("gathering tlsa records failed", err, mlog.Field("danerequired", daneRequired), mlog.Field("basedomain", tlsaBaseDomain))
|
||||
return daneRequired, nil, tlsaBaseDomain, err
|
||||
}
|
||||
daneRequired = len(l) > 0
|
||||
l = filterUsableTLSARecords(log, l)
|
||||
@ -329,7 +331,7 @@ func lookupTLSACNAME(ctx context.Context, log *mlog.Log, resolver dns.Resolver,
|
||||
return nil, fmt.Errorf("looking up tlsa records for tlsa candidate base domain: %w", err)
|
||||
} else if !result.Authentic {
|
||||
log.Debugx("tlsa lookup not authentic, not doing dane for host", err, mlog.Field("host", host), mlog.Field("name", name))
|
||||
return nil, err
|
||||
return nil, nil
|
||||
}
|
||||
return l, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user