cmdeploy/opendkim/final.lua: Strip OpenDKIM headers after validation

This commit is contained in:
j4n
2025-12-03 20:50:19 +01:00
parent 0e7ab96dc8
commit f840ea761e
2 changed files with 11 additions and 4 deletions

View File

@@ -28,8 +28,8 @@ for i = 1, nsigs do
end
end
if valid then
-- Strip all DKIM-Signature headers after successful validation
if not valid then
odkim.set_reply(ctx, "554", "5.7.1", "No valid DKIM signature found")
-- Delete in reverse order to avoid index shifting.
for i = nsigs, 1, -1 do
odkim.del_header(ctx, "DKIM-Signature", i)
@@ -37,6 +37,13 @@ if valid then
else
odkim.set_reply(ctx, "554", "5.7.1", error_msg)
odkim.set_result(ctx, SMFIS_REJECT)
return nil
end
-- Valid signature found. Strip all DKIM-Signature headers
-- Delete in reverse order to avoid index shifting.
for i = nsigs, 1, -1 do
odkim.del_header(ctx, "DKIM-Signature", i)
end
return nil

View File

@@ -272,8 +272,8 @@ by OpenDKIM screen policy script before validating the signatures. This
corresponds to strict :rfc:`DMARC <7489>` alignment (``adkim=s``).
If there is no valid DKIM signature on the incoming email, the
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.
After validating the DKIM signature, OpenDKIM strips all ``OpenDKIM:`` headers to
reduce message size.
Note that chatmail relays