Skip to content

Add provider-neutral signing for finalized MIME bytes #28

Closed

Description

@bbottema

Applications that finalize MIME before signing cannot use the existing signing route without Angus. DkimMessage extends Angus SMTPMessage, and the existing signer's protected signing method accepts that wrapper. A provider-neutral caller therefore has to maintain a separate signing implementation. The existing usage is: java DkimSigner signer = new DkimSigner("example.com", "mail", rsaPrivateKey); DkimMessage signed = new DkimMessage(message, signer); signed.writeTo(output); Add a separate DkimByteSigner with a builder accepting the signing domain, selector, java.security.PrivateKey, the existing signing-algorithm and canonicalization enums, and the applicable signing choices. Its sign(byte[] finalizedMessage) method returns a new complete message with a DKIM header prepended, preserving all supplied message bytes. Configuration and key compatibility are checked at build(); DNS checking remains a signing-time operation. The completed signer is immutable and keeps cryptographic state local to each call. Both entry points must use one internal DKIM engine. Keep the existing public and protected APIs, DkimMessage inheritance, subclass customization hooks, Java 8 baseline, module/package identity, transitive dependency setup, defaults, key formats, DNS policy, exception timing and resource ownership. In particular, the existing sign(DkimMessage) and getEncodedBody() overrides must still participate in legacy signing. The new entry point must run without Angus and must not change the JVM provider list, including while processing Ed25519 DNS keys. Preserve relaxed headers/simple body as upstream defaults; callers such as SJM can explicitly choose relaxed/relaxed. Ed25519 uses the SHA-256 header digest required by RFC 8463 section 3, while RSA retains its algorithm-specific hashing. The maintainer accepted this additive design on 23 October 2026, conditional on backwards compatibility and an Angus-free SJM signing path. The additive entry point is available in 3.4.0. Governing boundaries are SJM ADR 0007, ADR 0008 and the existing compatibility contract. This does not change the deferred line-ending or relaxed-whitespace policies in #25 and #26, remove SHA-1, change key-strength/DNS policy, or authorize a release. The existing published API remains supported. SJM integration is tracked in simple-java-mail#855. The durable signing-ownership decision belongs in SJM ADR 0008; exact public API details remain in the feature design.

Activity

  1. added this to the 3.4.0 milestone on Oct 23, 2026
  2. bbottema commented on Oct 23, 2026

    @bbottema
    MemberAuthor
    DkimByteSigner signer = DkimByteSigner.builder()
        .signingDomain("example.com")
        .selector("mail")
        .privateKey(privateKey)
        .build();
    
    byte[] signedMessage = signer.sign(finalizedMessageBytes);

    Available in utils-mail-dkim 3.4.0. The additive byte-signing entry point shares the existing DKIM engine while preserving legacy callers, defaults, protected hooks and Java 8. It retains the supplied message bytes and can run without Angus or JVM-global provider registration. Existing DkimMessage callers retain their dependency setup.

    Implemented in 73622c9. SJM ADR 0008 owns the signing/finalization boundary; downstream integration is tracked in SJM #855.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions