[ DKIM ]

DKIM public-key syntax: identify truncated or malformed DNS values

Reconstruct the actual DNS value, validate the selector key and distinguish formatting damage from a cryptographic mismatch.

By the EmailAuth research team

[ Key points ]

  • Build the lookup name from the affected signature’s d and s values.
  • Concatenate strings within one TXT record without adding whitespace.
  • Validate tags, decoded key type and the active signer separately.
On this page

When a DKIM key appears in a DNS control panel but verification fails, inspect the answer the verifier actually retrieves. Screenshots can hide a truncated value, a duplicated domain suffix or multiple independent records. The task is to establish the exact owner name and key bytes before changing the signer.

Start from the received signature

Read d= and s= from the affected DKIM-Signature. The lookup name combines them as selector._domainkey.signing-domain. A synthetic message with d=example.com and s=notify therefore uses notify._domainkey.example.com. A key published at notifications._domainkey.example.com will not repair it.

Record the signature's algorithm and the receiver's exact reason. Missing key, malformed key, unsuitable algorithm, signature mismatch and body-hash mismatch are not interchangeable diagnoses. If multiple signatures exist, keep their selectors and outcomes separate.

Reconstruct one TXT record correctly

DNS TXT records can contain multiple character strings. RFC 6376 §3.6.2.2 requires those strings within a single record to be concatenated without added whitespace before use. Splitting a long key across strings in one record differs from creating multiple TXT records, each containing a piece. The latter is not a safe way to publish one DKIM key. Section 3.6.2.2 requires a unique TXT record for the selector and leaves multiple-record results undefined; the verifier choices in section 6.1.2 do not make fragments composable.

Quoted chunks shown by a DNS tool are a presentation of the record. Do not assume display quotes are literal key bytes, and do not remove characters indiscriminately from the DNS interface. Follow its supported entry format, query authoritative DNS and compare the reconstructed value with the generated public value. RFC 1035 §3.3.14 defines the TXT character-string representation.

Inspect for truncation at interface limits, pasted line labels, missing separators and accidental edits to the base64 value. Long records need exact comparison, not visual inspection of the first and last few characters. Preserve the original generated public value for that comparison; never substitute a private-key file.

Validate tags and key material together

Under RFC 6376 §3.6.1, the p= tag carries the public-key data. An empty value means revoked, not a partially completed setup. The k= tag identifies the key type, with RSA as the default in RFC 6376; Ed25519 uses the extension defined by RFC 8463 §4.2. RFC 6376 section 3.6.1 formally marks the key-record v= tag RECOMMENDED, with DKIM1 as the default when it is absent. If included, it must be the first tag and its value must be exactly DKIM1; that value is case-sensitive.

Use a maintained DKIM-aware validator to parse the complete record and confirm that decoded public material is appropriate for the stated key type. Valid base64 alone does not prove that the content is a suitable RSA or Ed25519 public key. Likewise, a syntactically valid record can hold the wrong public key for the active private signer.

Isolate the publication layer from the signing layer

An illustrative failure involves a 2048-bit RSA public key copied into two separate TXT records. Repair the representation to the DNS provider's supported multi-string single-record form, then read back the answer. Do not shorten the key to silence the interface error without reviewing the cause and security implications.

If the correct public key resolves intact but a message still fails, investigate the active selector mapping, matching key pair, algorithm and signed-message changes. Do not keep republishing identical DNS data while the evidence points elsewhere. A provider-managed CNAME should be traced to its final key record; it should not be replaced with a local copy as a generic syntax workaround.

Prove the repair on a fresh message

Record authoritative and recursive results, accounting for cached old or negative answers. Send through the affected application and inspect the trusted recipient's result. Retain the corrected owner name, reconstructed public value or its digest, generated-value comparison and test evidence. A repair is complete when the retrieved key and actual signer agree, not merely when the DNS editor accepts the form.

Check structure without a real key

Illustrative one-record presentation: "v=DKIM1; k=rsa; p=AB" "CD". Concatenation produces v=DKIM1; k=rsa; p=ABCD, with no inserted space between AB and CD. ABCD is deliberately not a valid usable RSA public key; this example demonstrates TXT structure only and must not be published. Two separate records ending in p=AB and containing CD are not equivalent. After reconstructing the real generated value, a DKIM-aware parser must still validate its tags and decoded key material.

DKIM TXT and CNAME publishing: follow the provider's key-management model · DKIM key length and algorithms: check current receiver support.

[ Takeaway ]

Build the lookup name from the affected signature’s d and s values. Concatenate strings within one TXT record without adding whitespace. Validate tags, decoded key type and the active signer separately.

[ By role ]

What this means for you

Choose your role for practical next steps.

IT / Mail Admin

Compare reconstructed values.

Control-panel appearance does not establish the bytes returned by DNS.

Next steps

  1. Check one-record string concatenation.
  2. Test the matching signer.
  3. Compare the resolved key with generated data.

CISO / SecOps

Keep public and private material separate.

A debugging workflow must not expose the secret while repairing its public counterpart.

Next steps

  1. Use public-value digests.
  2. Review diagnostic upload practices.
  3. Keep private keys out of support evidence.

Founder / Non-technical

Repair the actual failure.

Repeated DNS changes can prolong an outage when the defect is in the signer or routing path.

Next steps

  1. Require the exact diagnostic reason.
  2. Prioritise affected transactional mail.
  3. Require a fresh application test before closure.

[ FAQs ]

Frequently asked questions

Can a DKIM TXT record contain multiple quoted strings?

Yes. Strings within one record are concatenated without added whitespace before DKIM processing.

RFC 6376 §3.6.2.2

Can I put half the key in each of two TXT records?

Do not use separate records as fragments of one key. Use the DNS provider’s supported representation of one complete record.

RFC 6376 §3.6.2.2

Does valid base64 prove the key is correct?

No. The decoded data must match the required key type and the active signing key pair.

RFC 6376 §6.1.2 RFC 8463 §4.2

What does p= with no value mean?

It is an explicit revoked-key value, not a placeholder awaiting completion.

RFC 6376 §3.6.1

Is the v tag optional?

The key-record v tag may be absent, but RFC 6376 formally marks it RECOMMENDED, with DKIM1 as its default. If present, it must be first and its value must be exactly DKIM1, case-sensitive.

RFC 6376 §3.6.1

Why start with a received message?

Its d and s values identify the exact owner name the verifier needs, avoiding repairs to an unused selector.

RFC 6376 §3.6.2.1

Will publishing a larger key fix a body-hash mismatch?

No. Investigate the signed message content and processing path for that diagnostic result.

RFC 6376 §6.1.3

How do I confirm a syntax repair?

Read back and parse the authoritative value, compare recursive answers, then verify a fresh message from the affected sender.

[ Sources ]

Sources

  1. RFC 6376

    Sections §1 · §2.1 · §3.5 · §3.6.1 · §3.6.2.1 · §3.6.2.2 · §6.1.2 · §6.1.3 · §3.6 · §8.3

  2. RFC 1035

    Sections §3.3.14

  3. RFC 8463

    Sections §4.2

  4. RFC 2308

    Sections §5

[ Glossary ]

Glossary

DKIM
A domain-associated signature over selected message headers and body content that a receiver verifies with public-key data.

RFC 6376 §1

DNS TXT
A DNS record type carrying text strings, including DKIM public verification data.

RFC 1035 §3.3.14

selector
The s value used with the signing domain to locate DKIM verification data.

RFC 6376 §3.5

public key
Verification material published for receivers; it is distinct from the secret signing key.

RFC 6376 §3.6 RFC 6376 §8.3

Enterprise provenance

Why top financial institutions and governments retired their email security dashboards.

Traditional email authentication platforms sell you a dashboard and ask your engineers to do the labour. In high-stakes environments, manual oversight means delayed enforcement, configuration drift and unmonitored shadow domains.

EmailAuth is the agentic email provenance platform. Our agents enforce p=reject, keep third-party senders aligned and move your domains to full RFC 9989 compliance, the new DMARC standard,, with human-in-the-loop auditability.

Governments Large enterprises Tier-1 financial institutions

SaaS · Dedicated tenancy · Air-gapped on-prem · BYOK encryption

Knowledge Base