Propagation delay is the constraint on unattended DKIM rotation; faster cutover is useful only after the replacement selector is usable. TL;DR: publish the new public key, verify the exact TXT value through the DNS path that matters, and keep signing with the current selector until the cutover gate passes. For fintech onboarding, require a separate, tenant-bound domain-control challenge before enabling sending. A successful DNS write is insufficient evidence for either decision.

The implementation below uses Go. The same state transitions apply to a Node.js scheduler: language choice does not remove the gap between publishing a record and a receiver being able to retrieve it.

What page fired before onboarding completed?

Consider a production-readiness drill, with hypothetical inputs rather than a reported incident: a fintech tenant wants to onboard notices.merchant.example, the current selector is active, and the replacement selector is candidate. In that drill, I would start the postmortem with one question: what page fired? “DNS update accepted” is a job event. “Onboarding deadline exceeded while the candidate key was still absent from a recursive lookup” identifies an operational problem that someone can investigate.

Hold the cutover.

The tempting interpretation is that the publish operation completed, so verification can be a background concern. That interpretation puts the irreversible business transition ahead of its evidence: onboarding can finish while a sender is still unable to demonstrate the expected authentication behavior, or a signing configuration can move before receivers can find its public key. A green dashboard aggregates those events too easily. The invariant should live in the transition itself: no activation without current authorization, verified candidate DNS, and an unchanged rotation generation.

For this example, the two selector names are configuration inputs, not a recommendation to reuse those names for every rotation. Each actual rotation should allocate a fresh selector and track its generation. That makes an old retry distinguishable from the current operation and avoids turning cached data for a reused name into evidence for a different key.

There are also two different meanings of “verified” here. A tenant-bound challenge can demonstrate control of the requested DNS name under the application's enrollment policy. A DKIM lookup retrieves a public key used to verify a message signature. Neither a successful TXT write nor the presence of an arbitrary DKIM record establishes which application tenant should receive permission to send.

Separate the ownership gate from the mail authentication gate

DKIM locates the public key using the signature's selector and signing domain, producing a name such as candidate._domainkey.notices.merchant.example. The private key stays with the signing system; the public key is published in DNS. RFC 6376 describes that division. Publishing the private key would defeat it.

DMARC adds another boundary. Under RFC 7489, a passing DKIM signature contributes to DMARC only when its signing domain aligns with the message's visible From domain according to the applicable alignment mode. SPF can also provide an aligned authentication result. Therefore, “the candidate TXT exists” is a useful deployment check, but it is not an end-to-end assertion that a real message passes DMARC. The sender must still sign correctly, and the domain relationship must satisfy the policy.

For onboarding, use an application-generated challenge tied to the tenant, exact requested domain, enrollment attempt, and expiration. Those bindings are a proposed application policy, not a DKIM protocol requirement. Keep the challenge check separate from key publication so a stale challenge, a canceled enrollment, or a successful rotation for another tenant cannot authorize the new enrollment. If delegated subdomains are supported, document which requested name the challenge authorizes; do not silently expand a narrow proof into permission over a parent domain.

This is where a postmortem needs precision. “Verification passed” conceals too much. Record whether the application established tenant authorization, observed the expected public key, or verified an actual signed message. Those are separate pieces of evidence, with different consumers and different failure consequences.

Spend propagation time before the business cutover

DNS caching creates the timing problem. RFC 1035 defines TTL behavior for cached resource records, and RFC 2308 describes negative caching. A resolver that recently received a negative answer can retain that result even after the authoritative service has the new record. Lowering a TTL after a lookup does not retroactively erase a cached answer.

There is no universal propagation sleep that proves readiness.

The practical alternatives differ in when they spend that uncertainty:

Approach Benefit Operational cost
Publish a fresh selector before switching Existing signing can continue while the candidate becomes visible Requires tracking two key generations and a later retirement decision
Switch immediately after the DNS write Removes the observation wait from the deployment path Receivers may query before they can retrieve the candidate key
Keep onboarding pending until evidence passes Makes domain authorization an explicit completion condition Adds latency and requires a useful pending state for the tenant

For the fintech enrollment in this example, choose the first and third approaches together. Publish early, leave onboarding pending, and keep the current signer active during rotation. The trade-off is explicit: accept slower onboarding because an inspectable gate keeps business completion behind its authorization evidence. It also separates two deadlines: the enrollment deadline determines when a stalled onboarding deserves attention, while the rotation deadline determines how long an existing sender may remain on its current generation.

Check authoritative publication when diagnosing a failed DNS write, and check recursive resolution when evaluating the cache behavior a receiver may encounter. One recursive success cannot prove that every receiver worldwide has refreshed its cache. Record what was observed and where; an observation policy is a bounded operational decision, not a claim of global convergence.

TXT handling deserves a test of its own. RFC 1035 permits multiple character strings within a TXT record, with each character string limited to 255 octets. Concatenate those strings within each individual record before comparing its logical value, but do not concatenate separate TXT records into one synthetic key. Compare the expected DKIM key material and parameters through an appropriate parser. A substring match for the selector name or the prefix v=DKIM1 provides almost no evidence that the intended public key was published.

When should an unattended DKIM rotation job publish TXT and alert?

The following Go code is an orchestration boundary, not a DNS provider client or a DKIM implementation. Its adapters must supply the contracts described below. Keeping those contracts explicit makes the important failure paths testable without pretending that a DNS write and a database transition form one transaction.

package rotation import ( "context" "errors" "fmt" "time" ) var ErrPending = errors.New("candidate DNS is not ready") type Plan struct { TenantID, Domain, Generation string Selector, PublicTXT string Deadline time.Time } type Gate interface { // Check the tenant-bound challenge and current enrollment authorization. Authorized(context.Context, Plan) (bool, error) // Idempotently publish only the expected public record for this generation. Publish(context.Context, Plan) error // Parse TXT records and enforce the configured DNS observation policy. Observe(context.Context, Plan) (bool, error) // Atomically recheck authorization and generation, then activate once. ActivateIfCurrent(context.Context, Plan) error } type Alerter interface { // Deduplicate on tenant, domain, generation, and failure reason. Page(context.Context, Plan, string) error } func Step(ctx context.Context, g Gate, a Alerter, p Plan, now time.Time) error { allowed, err := g.Authorized(ctx, p) if err != nil { return fmt.Errorf("check authorization: %w", err) } if !allowed { return errors.New("domain authorization is not current") } if !now.Before(p.Deadline) { if err := a.Page(ctx, p, "cutover deadline exceeded"); err != nil { return fmt.Errorf("deliver deadline alert: %w", err) } return errors.New("cutover deadline exceeded") } if err := g.Publish(ctx, p); err != nil { return fmt.Errorf("publish candidate: %w", err) } ready, err := g.Observe(ctx, p) if err != nil { return fmt.Errorf("observe candidate: %w", err) } if !ready { return ErrPending } if err := g.ActivateIfCurrent(ctx, p); err != nil { return fmt.Errorf("activate candidate: %w", err) } return nil } 

ActivateIfCurrent is the critical contract. It must reject a superseded generation or expired authorization even if the earlier check succeeded, because a job can pause between any two calls. If the signer lives outside the state store, activation needs a durable, idempotent reconciliation step; a comment on an interface does not create atomicity across systems. Persist the desired generation, reconcile the signer to that generation, and record confirmation before calling the transition complete.

Likewise, Publish needs a restricted write scope. Its retry must not overwrite a newer generation or replace unrelated records. The plan carries public TXT data only; private-key creation and storage belong behind the signing boundary, and the DNS publisher should not need access to those secrets.

The scheduler should treat ErrPending as an expected wait, persist its next attempt, and retry with bounded backoff and jitter. Transport errors need a separate retry policy. A permanent authorization failure should leave enrollment blocked and produce a useful status, while failure to deliver a page must be visible through the job runner's own failure reporting. Otherwise the alert path can disappear with the same worker it is supposed to supervise.

Test the missing record, then test the stale worker

The most revealing test sequence is deliberately inconvenient: publication succeeds, the first recursive observation is negative, a later observation returns the correct candidate, and a stale worker tries to activate after the generation has changed. The expected outcomes are pending, pending until evidence satisfies the policy, and rejection of stale activation. Add cases for a wrong public key, split TXT strings, multiple distinct records, an expired challenge, duplicate execution, and an unavailable alert destination.

Then send a controlled message through the actual signing path and inspect its authentication results. DNS tests cannot establish that the signer selected the intended private key or produced an aligned signature. RFC 8301 also updates DKIM cryptographic requirements; key generation and validation should follow current applicable requirements rather than treating a syntactically valid TXT value as sufficient.

During deployment, start with observation-only execution and inspect the planned state transitions before enabling activation. Keep durable timestamps for publication, observations, activation, and alert attempts, plus the generation and lookup outcome. Avoid placing private keys or challenge values in logs. Don't trust the summary alone. A dashboard can summarize that evidence, but an incident responder needs the underlying transition history and the reason the gate stayed closed.

Polling has a budget. More frequent queries consume resolver capacity and worker time without forcing other caches to expire. Backoff reduces that load at the cost of slower detection after the answer changes; expose that trade-off in the onboarding status instead of calling every pending lookup a failure.

When should this waiting policy change?

Suspected private-key compromise changes the decision. Keeping the old selector available for routine continuity may conflict with the need to stop trusting the compromised key; RFC 6376 describes key revocation, and the response must account for cached data rather than promise instant invalidation. Routine retirement also needs a separate policy for messages already signed with the old selector and still awaiting verification. The successful activation of a replacement is not, by itself, proof that the old public key can safely disappear.

A first-time sender has no existing signing generation to preserve, so it should remain pending until the onboarding gates pass. A planned rotation can usually spend propagation time while the old authorized signer continues working. Keep those cases distinct.

The operational conclusion is narrow: complete onboarding only on the evidence that authorizes it, switch signing only on the evidence that supports it, and page on a breached deadline with enough state to explain the blocked transition. A completed job run is just a completed job run.

References

The standards below define the authentication and DNS behavior; the enrollment bindings, observation policy, and retry strategy above are application design choices.

Sources