Package com.mimecast.robin.signing
Class DkimSigningHelper
java.lang.Object
com.mimecast.robin.signing.DkimSigningHelper
Applies DKIM signatures to outbound
RelaySession envelope files.
Every code path that enqueues an outbound message to the persistent relay queue must
invoke applyDkimSignaturesIfEnabled(RelaySession) before enqueueing, so that
the signature is baked into the file that the queue processor later delivers. Retries
of a queued file therefore transmit the already-signed bytes unchanged.
There are two such call sites today:
RelayMessage.deliver()— messages accepted over SMTP with an outboundSession.BotHelper.queueBotResponse()— bot-generated responses that construct an outbound session in-process rather than receiving one over SMTP.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyDkimSignaturesIfEnabled(RelaySession relaySession) Signs each envelope file in the session (in place, on disk) with every configured (domain, selector) pair returned byDkimSigningLookupfor the envelope's sender domain.private static StringextractSenderDomain(String mail) Extracts the domain part from an email address.private static voidprependDkimSignatures(File emailFile, byte[] original, List<String> signatures) PrependsDKIM-Signatureheaders to the email file.private static StringreadPrivateKey(String keyPath) Reads a PKCS8 PEM private key file and returns the base64 content without PEM headers.
-
Field Details
-
log
private static final org.apache.logging.log4j.Logger log
-
-
Constructor Details
-
DkimSigningHelper
private DkimSigningHelper()
-
-
Method Details
-
applyDkimSignaturesIfEnabled
Signs each envelope file in the session (in place, on disk) with every configured (domain, selector) pair returned byDkimSigningLookupfor the envelope's sender domain. Idempotent per call: skips when DKIM signing is not enabled, when no signing key is configured, when the sender domain has no lookup rows, or when the envelope has no file.- Parameters:
relaySession- Session whose envelope files should be signed prior to enqueue.
-
readPrivateKey
Reads a PKCS8 PEM private key file and returns the base64 content without PEM headers.- Parameters:
keyPath- Path to the PEM key file.- Returns:
- Base64 key content (no PEM headers/footers, single line).
- Throws:
IOException- If the file cannot be read.
-
prependDkimSignatures
private static void prependDkimSignatures(File emailFile, byte[] original, List<String> signatures) throws IOException PrependsDKIM-Signatureheaders to the email file.- Parameters:
emailFile- Email file to modify in place.original- Original email content (already read from the file).signatures- List of DKIM-Signature header values (already RFC 5322 folded by Rspamd).- Throws:
IOException- If the file cannot be written.
-
extractSenderDomain
Extracts the domain part from an email address.- Parameters:
mail- Email address (e.g.,"user@example.com").- Returns:
- Domain, or null if no
@is present.
-