This is partly a report from helping build DKIM2 support into the IETF mail 
infrastructure during the code sprint yesterday and today.

A good pattern.

*At ingress*

Have some kind of internal header (e.g. X-DKIM2-Arrival) - this is ALWAYS 
STRIPPED on ingress, and then your very first hop validates the incoming DKIM2. 
 There are 4 possible values: none, pass, temperror, permerror.  You basically 
treat these as two buckets: for none/pass you keep doing dkim2, for the error 
cases you just leave it along and don't do any further processing.

Next, for the 'none' case, stamp a Message-Instance on the message giving its 
state on receipt.

OPTIONALLY: store a copy of the message indexed by the hash of its 
message-instance header (or some unique key which you generate).

Set the X-DKIM2-Arrival header on the message.  This will be used at Egress.

*At each hop*

Calculate a recipe which describes the changes you made at this hop, if any.  
OPTIONALLY also verify the top Message-Instance before making changes so you 
know that your pipeline is safe.

*At egress*

If X-DKIM2-Arrival says that the message was valid on the way in, check that 
the top Message-Instance describes the message still.  If so, sign it.  If not 
AND you took a copy of the message as it came in, calculate the recipe now 
using that original message, and add a Message-Instance which says that 
(stripping any Message-Instance headers added by internal hops first).

NOTE: if any of the Message-Instance headers you created rewrote the message 
body and didn't change the From address, this is also a good place to rewrite 
the From address (and include it in the top Message-Instance's recipe) before 
signing.

....

This pattern appears to cover some pretty complex setups.  You basically have 
two choices:

a) update EVERY step to describe any changes it makes, or
b) take a snapshot on the way in and run a diff on the way out

(you can keep 'b' as a belt-and-suspenders, the outbound tool won't need it if 
the top Message-Instance already describes the message)

Bron.

--
  Bron Gondwana, CEO, Fastmail Pty Ltd / Fastmail US LLC
  [email protected]
_______________________________________________
Ietf-dkim mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to