What is Dkim?

DKIM stands for DomainKeys Identified Mail. It is an email authentication method that allows the sender of an email to digitally sign the message with a private key. This digital signature provides a way for the recipient’s email system to verify that the email was actually sent by the claimed sender and that the content of the email has not been tampered with during transit.
Table of Contents
DomainKeys Identified Mail explained: How Its Works

DKIM (DomainKeys Identified Mail) is an email authentication method that adds a digital signature to the headers of an email message. This signature is generated using a private key, and the recipient can verify its authenticity using a public key published in the sender’s DNS records. Here’s a step-by-step explanation of how DKIM works:
- Key Generation:
- The sender generates a pair of cryptographic keys: a private key and a corresponding public key.
- The private key is kept secure and is used to create the digital signature.
- The public key is published in the DNS records associated with the sender’s domain.
- Email Signing:
- When the sender sends an email, the DKIM process begins.
- A specific set of email headers (typically including the “From” and “Subject” fields) and the body of the email are hashed using a cryptographic hash function.
- The hash result is then signed with the sender’s private key, creating the digital signature.
- The digital signature is added to the email header as a DKIM-Signature field.
- DNS Record Publication:
- The sender publishes the public key in their DNS records. This is often done as a TXT (text) record associated with their domain.
- The public key allows recipients to verify the digital signature created by the private key.
- Email Transmission:
- The signed email is transmitted to the recipient.
- Verification:
- When the recipient’s email server receives the email, it retrieves the sender’s public key from the DNS records.
- The server uses the public key to verify the digital signature in the DKIM-Signature field.
- If the signature is valid, it indicates that the email was sent by the claimed sender and that its content has not been altered in transit.
- If the signature is invalid or missing, the recipient’s email system may treat the email with suspicion or apply specific policies according to the organization’s DMARC (Domain-based Message Authentication, Reporting, and Conformance) settings.
Why does DomainKeys Identified Mail store keys in DNS?
DomainKeys Identified Mail stores public keys in DNS (Domain Name System) for a few important reasons:
Distribution of Public Keys
Storing DomainKeys Identified Mail public keys in DNS allows for a centralized and widely accessible location from which receiving email servers can retrieve the public key associated with a specific domain. This ensures that anyone who receives an email can easily obtain the necessary information to verify the digital signature.
Verification of Sender Authenticity
The primary purpose of DKIM is to verify the authenticity of the sender of an email. The sender signs the email with a private key, and the recipient uses the corresponding public key to verify the signature. By publishing the public key in DNS, the recipient’s email server can reliably retrieve the key to perform this verification.
Dynamic Key Rotation
DKIM provides a mechanism for rotating or changing the keys periodically for security reasons. Storing the public key in DNS allows for easy updates. Organizations can update their keys by publishing a new public key with a different selector in DNS, and email recipients will automatically use the updated key when verifying future emails.
Decentralized Key Management
By using DNS, DKIM leverages the existing infrastructure of the internet for key distribution. This decentralized approach allows domain owners to manage their keys independently, and it eliminates the need for a centralized key distribution system.
Scalability and Standardization
DNS is a widely used and scalable system on the internet. By utilizing DNS for key storage, DKIM leverages an existing, well-established protocol, promoting interoperability and ease of implementation across different email systems.
Here’s a simplified overview of the process:
- The sender generates a pair of cryptographic keys (private and public).
- The sender publishes the public key in DNS as a TXT record associated with a specific selector and domain.
- When an email is sent, the digital signature in the DKIM-Signature header points to the selector in DNS.
- The recipient’s email server retrieves the public key from DNS using the selector to verify the email’s authenticity.
DomainKeys Identified Mail authentication limitations
While DKIM (DomainKeys Identified Mail) is a valuable tool for email authentication, it does have some limitations:
- Partial Email Security: DomainKeys Identified Mail focuses on authenticating the sender of an email and ensuring that the content has not been tampered with in transit. However, it doesn’t encrypt the email content, so it doesn’t provide end-to-end security or confidentiality.
- No Protection Against Intercepted Keys: If the private key used for signing DKIM is compromised or intercepted, an attacker could sign malicious emails that appear legitimate. This emphasizes the importance of securing the private key.
- Key Management Challenges: Proper key management is crucial for DKIM to be effective. Organizations need to securely generate, store, and rotate their keys. If not done correctly, key management issues can lead to security vulnerabilities.
- Limited to Signature Verification: DKIM focuses on verifying the signature of an email. It doesn’t address other email security aspects, such as determining if an email is spam or phishing. Combining DKIM with other mechanisms like SPF (Sender Policy Framework) and DMARC (Domain-based Message Authentication, Reporting, and Conformance) enhances overall email security.
- No User Authentication: DKIM does not authenticate the individual sender within an organization. It authenticates the domain, not the user. In a scenario where multiple users send emails on behalf of a domain, DKIM alone might not provide granularity in identifying the specific sender.
- Reliance on DNS: DKIM relies on DNS to publish and retrieve public keys. If there are issues with DNS security or availability, it can impact DKIM verification. However, DNS is a fundamental part of internet infrastructure, and widespread issues are relatively uncommon.
- Limited Adoption: While DKIM is widely supported, its effectiveness depends on widespread adoption. If email senders or receivers do not implement DKIM, its benefits are limited. Fortunately, DKIM has gained significant adoption over the years.
- Potential for Misconfigurations: Misconfigurations, such as incorrect key publication or inconsistent use of selectors, can lead to DKIM failures. Regular monitoring and auditing are necessary to ensure proper implementation.
- Complexity for Small Businesses: Implementing and managing DKIM can be more challenging for small businesses with limited IT resources. They may find it challenging to handle key management and configuration correctly.