mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
Remove DKIM-Signature from incoming mail after checking (#747)
The original https://github.com/chatmail/relay/pull/533 attempted to remove the header through postfix, but that is too early. Instead, remove the headers in the OpenDKIM `final.lua` script after the validation.
This commit is contained in:
@@ -9,9 +9,10 @@ if nsigs == nil then
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local valid = false
|
||||||
for i = 1, nsigs do
|
for i = 1, nsigs do
|
||||||
sig = odkim.get_sighandle(ctx, i - 1)
|
sig = odkim.get_sighandle(ctx, i - 1)
|
||||||
sigres = odkim.sig_result(sig)
|
sigres = odkim.sig_result(sig)
|
||||||
|
|
||||||
-- All signatures that do not correspond to From:
|
-- All signatures that do not correspond to From:
|
||||||
-- were ignored in screen.lua and return sigres -1.
|
-- were ignored in screen.lua and return sigres -1.
|
||||||
@@ -19,10 +20,19 @@ for i = 1, nsigs do
|
|||||||
-- Any valid signature that was not ignored like this
|
-- Any valid signature that was not ignored like this
|
||||||
-- means the message is acceptable.
|
-- means the message is acceptable.
|
||||||
if sigres == 0 then
|
if sigres == 0 then
|
||||||
return nil
|
valid = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if valid then
|
||||||
|
-- Strip all DKIM-Signature headers after successful validation
|
||||||
|
-- Delete in reverse order to avoid index shifting.
|
||||||
|
for i = nsigs, 1, -1 do
|
||||||
|
odkim.del_header(ctx, "DKIM-Signature", i)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
odkim.set_reply(ctx, "554", "5.7.1", "No valid DKIM signature found")
|
||||||
|
odkim.set_result(ctx, SMFIS_REJECT)
|
||||||
end
|
end
|
||||||
|
|
||||||
odkim.set_reply(ctx, "554", "5.7.1", "No valid DKIM signature found")
|
|
||||||
odkim.set_result(ctx, SMFIS_REJECT)
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -273,9 +273,11 @@ Incoming emails must have a valid DKIM signature with
|
|||||||
Signing Domain Identifier (SDID, ``d=`` parameter in the DKIM-Signature
|
Signing Domain Identifier (SDID, ``d=`` parameter in the DKIM-Signature
|
||||||
header) equal to the ``From:`` header domain. This property is checked
|
header) equal to the ``From:`` header domain. This property is checked
|
||||||
by OpenDKIM screen policy script before validating the signatures. This
|
by OpenDKIM screen policy script before validating the signatures. This
|
||||||
correpsonds to strict :rfc:`DMARC <7489>` alignment (``adkim=s``).
|
corresponds to strict :rfc:`DMARC <7489>` alignment (``adkim=s``).
|
||||||
If there is no valid DKIM signature on the incoming email, the
|
If there is no valid DKIM signature on the incoming email, the
|
||||||
sender receives a “5.7.1 No valid DKIM signature found” error.
|
sender receives a “5.7.1 No valid DKIM signature found” error.
|
||||||
|
After validating the DKIM signature,
|
||||||
|
the `final.lua` script strips all ``OpenDKIM:`` headers to reduce message size on disc.
|
||||||
|
|
||||||
Note that chatmail relays
|
Note that chatmail relays
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user