mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 13:04:38 +03:00
bugfix: when dkim-signing submitted messages, use the domain from the "message from header" instead of "smtp mail from"
dmarc verifiers will only accept a dkim signature if the domain the message From header matches the domain of the signature (i.e. it is "aligned"). i hadn't run into this before and when testing because thunderbird sets the "smtp mail from" to the same address as a custom "message from" header. but other mail clients don't have to do that. should fix issue #22
This commit is contained in:
@ -1737,19 +1737,18 @@ func (c *conn) submit(ctx context.Context, recvHdrFor func(string) string, msgWr
|
||||
// todo future: in a pedantic mode, we can parse the headers, and return an error if rcpt is only in To or Cc header, and not in the non-empty Bcc header. indicates a client that doesn't blind those bcc's.
|
||||
|
||||
// Add DKIM signatures.
|
||||
domain := c.mailFrom.IPDomain.Domain
|
||||
confDom, ok := mox.Conf.Domain(domain)
|
||||
confDom, ok := mox.Conf.Domain(msgFrom.Domain)
|
||||
if !ok {
|
||||
c.log.Error("domain disappeared", mlog.Field("domain", domain))
|
||||
c.log.Error("domain disappeared", mlog.Field("domain", msgFrom.Domain))
|
||||
xsmtpServerErrorf(codes{smtp.C451LocalErr, smtp.SeSys3Other0}, "internal error")
|
||||
}
|
||||
|
||||
dkimConfig := confDom.DKIM
|
||||
if len(dkimConfig.Sign) > 0 {
|
||||
if canonical, err := mox.CanonicalLocalpart(c.mailFrom.Localpart, confDom); err != nil {
|
||||
c.log.Errorx("determining canonical localpart for dkim signing", err, mlog.Field("localpart", c.mailFrom.Localpart))
|
||||
} else if dkimHeaders, err := dkim.Sign(ctx, canonical, domain, dkimConfig, c.smtputf8, dataFile); err != nil {
|
||||
c.log.Errorx("dkim sign for domain", err, mlog.Field("domain", domain))
|
||||
if canonical, err := mox.CanonicalLocalpart(msgFrom.Localpart, confDom); err != nil {
|
||||
c.log.Errorx("determining canonical localpart for dkim signing", err, mlog.Field("localpart", msgFrom.Localpart))
|
||||
} else if dkimHeaders, err := dkim.Sign(ctx, canonical, msgFrom.Domain, dkimConfig, c.smtputf8, dataFile); err != nil {
|
||||
c.log.Errorx("dkim sign for domain", err, mlog.Field("domain", msgFrom.Domain))
|
||||
metricServerErrors.WithLabelValues("dkimsign").Inc()
|
||||
} else {
|
||||
msgPrefix = append(msgPrefix, []byte(dkimHeaders)...)
|
||||
|
Reference in New Issue
Block a user