✉️ 5. S/MIME: email encryption with certificates
← 4. TLS, WireGuard, FIDO2 and Signal · Overview
There are two standards for signing and encrypting email: OpenPGP (part 3) and S/MIME. They use the same mathematics. The big difference is the answer to the question every protocol has to answer: whose key is this? OpenPGP lets people vouch for each other (or you check a fingerprint yourself); S/MIME uses certificates from a certificate authority, exactly like HTTPS (part 4). That makes S/MIME the choice of companies, governments and universities: it is built into Outlook, Apple Mail, Thunderbird and most phones, and an organisation can hand out certificates centrally.
1. S/MIME and OpenPGP side by side
| S/MIME | OpenPGP | |
|---|---|---|
| Standard | RFC 8551 (S/MIME 4.0), on top of CMS (RFC 5652) | RFC 9580 / LibrePGP |
| Your public key comes as | an X.509 certificate, signed by a certificate authority (CA) | a key with user IDs, signed by yourself (and maybe others) |
| Who says the key is yours? | the CA, after checking (at least) that you control the email address | you, your contacts, a fingerprint check |
| Cost | free (Actalis), through your employer, or paid | free |
| Validity | at most 825 days, then a new certificate | as long as you want |
| Built into | Outlook, Apple Mail, iOS, Thunderbird, Evolution, Zimbra | Thunderbird, Proton Mail; others with plug-ins |
| Typical use | organisations, legal and government mail | individuals, open-source projects, journalists |
Both protect the content of the message and the attachments. Neither encrypts the headers: who mailed whom, when, and the subject line stay visible to every mail server on the way.
2. What a signed or encrypted message looks like
S/MIME packs everything in CMS (Cryptographic Message Syntax, the successor of PKCS #7) and then in a MIME part of the email.
Signed (multipart/signed): the message stays readable for everybody, and a part smime.p7s is attached with the signature. A mail program without S/MIME just shows an attachment it doesn’t understand.
Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256
--boundary
Content-Type: text/plain; charset=utf-8
Hello Benjamin, ...
--boundary
Content-Type: application/pkcs7-signature; name=smime.p7s
MIIG... (the CMS SignedData: hash, signature, the sender's certificate)
--boundary--
Encrypted (application/pkcs7-mime; smime-type=enveloped-data, or authEnveloped-data with AES-GCM; file name smime.p7m): the whole message, attachments included, is one encrypted blob. Inside:
- A fresh random content-encryption key (CEK), for example a 256-bit AES key.
- The message, encrypted with that key (AES-GCM in S/MIME 4.0, AES-CBC in older versions).
- For every recipient (and for yourself, so you can read your Sent folder): the CEK, locked with that person’s public key, together with the serial number of their certificate so their mail program knows which entry is theirs.
That is the same “random key, locked for each reader” construction as OpenPGP (part 3, section 2). Mail programs normally sign first, then encrypt, so the signature is hidden inside the encryption.
3. The mathematics inside
Every piece is a formula from part 1:
| Job | S/MIME 4.0 (RFC 8551) | Mathematics |
|---|---|---|
| Hash of the message | SHA-256 (SHA-512 allowed) | a one-way function |
| Signature | RSA (PKCS #1 v1.5 or RSA-PSS), ECDSA on P-256, Ed25519 | RSA, ECDSA and Schnorr/EdDSA |
| Locking the CEK for a recipient | RSA key transport (PKCS #1 v1.5 or RSA-OAEP), or ECDH (P-256, X25519) followed by AES key wrap | RSA, ECDH |
| Encrypting the content | AES-128/256-GCM (AES-CBC for old clients) | symmetric cipher |
| Trust in the certificate | the CA’s signature over your certificate, and the root’s over the CA | signatures, in a chain |
A whole S/MIME message with small numbers
Let’s run it with the toy keys from the practice pages.
Your certificate. You (Alice) have the RSA key from part 1: $n = 2773$, $e = 17$, private $d = 157$. A CA with the key $n_{CA} = 3233$, $e = 17$, $d_{CA} = 2753$ checked your email address and signed your certificate. Say the hash of the certificate’s content is $h = 100$:
$$\text{signature} = 100^{2753} \bmod 3233 = 1391$$Anybody who trusts the CA checks: $1391^{17} \bmod 3233 = 100$ ✓, so the public key $(2773, 17)$ in the certificate really belongs to alice@example.org.
Bob encrypts to you. Bob’s mail program picks a random content key, say $\text{CEK} = 1234$, encrypts the message with it, and locks the CEK with your public key:
$$1234^{17} \bmod 2773 = 1793$$The message carries “for the certificate with serial number X: 1793”.
You open it. Your mail program finds your entry, unlocks the CEK with your private key, $1793^{157} \bmod 2773 = 1234$, and decrypts the message with it.
With ECDH (an elliptic-curve certificate) step 2 is different: Bob makes a throwaway key pair, does an ECDH exchange with your public key, and uses the shared point (through a hash) to wrap the CEK; he sends his throwaway public key along. That is exactly what OpenPGP does with Curve25519 too (part 3).
⚠️ EFAIL (2018). AES-CBC without integrity protection let attackers change an encrypted message so that the recipient’s mail program leaked the plaintext (via an HTML image link). The fixes: mail programs no longer load external content in decrypted mail, and S/MIME 4.0 introduced AES-GCM (AuthEnvelopedData), which detects any change to the ciphertext.
4. Certificates and trust
An S/MIME certificate is an X.509 certificate, like a web server’s, with:
- your email address in the Subject Alternative Name (the mail program checks that it matches the
From:address), - the purpose email protection (Extended Key Usage
emailProtection), - your public key (RSA 2048+ or EC P-256/P-384),
- the CA’s signature, and a validity of at most 825 days.
Since September 2023 every publicly trusted CA follows the CA/Browser Forum S/MIME Baseline Requirements. They define four kinds of certificate:
| Validation | What the CA checked | Name in the certificate |
|---|---|---|
| Mailbox-validated | only that you can receive mail at the address | email address only |
| Organisation-validated | the organisation | organisation name |
| Sponsor-validated | the organisation, and it vouches for you | organisation and your name |
| Individual-validated | your identity (ID document) | your name |
For encrypting and signing between people who know each other, mailbox-validated is enough.
Keep your old keys. When your certificate expires you get a new one with a new key pair, but mail that was encrypted to the old certificate can only be opened with the old private key. Keep the old .p12 files (safely); never delete them from your mail program.
How do you get someone else’s certificate? The easiest way: they send you a signed message. The signature includes their certificate, and your mail program stores it. After that you can encrypt to them. In organisations, certificates are also published in the address book (Exchange GAL, LDAP).
5. Where to get a certificate
| Where | Cost | Notes |
|---|---|---|
| Your employer or university | free for you | Dutch universities and research institutes get them through SURF (GÉANT Trusted Certificate Service, issued by HARICA since 2025). Ask your IT department. |
| Actalis (Italy) | free, 1 year | Mailbox-validated. Actalis generates the private key for you and sends it as a .p12, so you have to trust them with it. |
| Commercial CAs: HARICA, Sectigo, DigiCert, GlobalSign, … | about €10–€60 per year (mailbox-validated) | Most let you upload your own CSR, so the private key never leaves your computer. |
| Your own CA (OpenSSL, step-ca) | free | Only works between people who install your CA as trusted, e.g. inside one organisation. |
Let’s Encrypt does not issue S/MIME certificates.
Make your own key and certificate request
If the CA accepts a CSR, make the key yourself; then it is never anywhere else:
# 1. Your private key (RSA 3072 works in every mail program; ECDSA P-256 is smaller)
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -out smime.key
chmod 600 smime.key
# 2. The certificate request (CSR) for your address
openssl req -new -key smime.key -subj "/emailAddress=you@example.org" -out smime.csr
# 3. Upload smime.csr to the CA; after the email check you get smime.crt (+ chain.pem)
# 4. Bundle key + certificate + chain into one password-protected file to import
openssl pkcs12 -export -inkey smime.key -in smime.crt -certfile chain.pem \
-name "S/MIME you@example.org" -out smime.p12
# (old Windows/Outlook versions that refuse the file: add
# -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -macalg sha1)
# Look inside your certificate
openssl x509 -in smime.crt -noout -subject -ext subjectAltName,extendedKeyUsage -dates
S/MIME also works on the command line, which is a good way to see what happens:
# sign (the result is a MIME message with an smime.p7s part)
openssl cms -sign -in message.txt -signer smime.crt -inkey smime.key -out signed.eml
# encrypt to a recipient's certificate with AES-256-GCM
openssl cms -encrypt -aes-256-gcm -in message.txt -out encrypted.eml bob.crt
# decrypt with your own key
openssl cms -decrypt -in encrypted.eml -recip smime.crt -inkey smime.key
# show the structure: the recipient entries, the algorithms
openssl cms -cmsout -print -in encrypted.eml | less
GnuPG speaks S/MIME too (gpgsm, and the graphical Kleopatra), and can keep the key on a smart card or YubiKey.
6. Set it up in your mail program
The steps are the same everywhere: import your .p12, choose it for signing and encryption, send a signed message to the people you want to write to, and encrypt once you have their certificate.
Thunderbird (version 128 and later)
- ☰ menu → Account Settings → your account → End-To-End Encryption.
- Under S/MIME click Manage S/MIME Certificates → tab Your Certificates → Import…, choose your
.p12and type its password. - Back under S/MIME: click Select… next to Personal certificate for digital signing and next to Personal certificate for encryption (usually the same certificate; Thunderbird offers to use it for both).
- Optional, in the same screen: Sign unencrypted messages and Require encryption by default.
- While writing: the Encrypt button and the Options menu (Digitally Sign, Require Encryption). If you also use OpenPGP, choose the technology under Options → S/MIME.
Thunderbird stores the certificates of people who send you signed mail automatically.
Outlook (classic, Windows)
- Double-click your
.p12file. The Windows Certificate Import Wizard puts it in your personal certificate store (Current User). - In Outlook: File → Options → Trust Center → Trust Center Settings… → Email Security.
- Under Encrypted email click Settings…: give the settings a name, choose your certificate for Signing Certificate and Encryption Certificate, set Hash Algorithm to SHA256 and Encryption Algorithm to AES (256-bit). Click OK.
- Optional: tick Add digital signature to outgoing messages (and Encrypt contents and attachments for outgoing messages if you want everything encrypted).
- Per message: tab Options → the Sign and Encrypt buttons (in Microsoft 365 versions under the Encrypt menu).
- Someone’s certificate: open a signed message from them, right-click their name → Add to Outlook Contacts. The certificate is saved in the contact.
New Outlook for Windows and Outlook on the web
Since 2025 the new Outlook supports S/MIME for work and school (Microsoft 365 / Exchange) accounts. Your certificate must be in the Windows certificate store (step 1 above) or on a smart card. Then: Settings → Mail → S/MIME, where you choose to sign and/or encrypt all outgoing messages; per message, the S/MIME choices are under Options in the window where you write. Your organisation’s administrator must have configured S/MIME for Exchange (Set-SmimeConfig); for Outlook on the web that also includes a browser extension.
Zimbra (Modern Web App, Zimbra 10)
S/MIME in Zimbra is a server-side feature that your administrator must switch on (it is off for everybody by default and needs the Secure Mail zimlet). Once it is on:
- Gear icon → Settings → S/MIME and Encryption → + Add a certificate, choose your
.p12or.pfx, type the password, Save. - Someone else’s certificate: Contacts → right-click the contact → Edit Details → Security Certificate → Add a certificate → choose their
.crt→ Save. - While writing: in the top-right corner of the compose window choose Sign or Sign and Encrypt instead of Do not sign or encrypt.
- Your default for new messages: Settings → S/MIME and Encryption.
Evolution (GNOME)
- Edit → Preferences → Certificates → tab Your Certificates → Import, choose your
.p12and type its password. - Edit → Preferences → Mail Accounts → select the account → Edit → tab Security.
- Under Secure MIME (S/MIME): Select your certificate for Signing certificate and for Encryption certificate. Optional: Always sign outgoing messages, Always encrypt to myself.
- While writing: Options → S/MIME Sign and S/MIME Encrypt (or the buttons in the toolbar).
- Other people’s certificates are in the same Preferences screen under Contact Certificates.
7. Common problems
| Problem | Cause and fix |
|---|---|
| “Encrypt” is greyed out / “no certificate for the recipient” | You don’t have their certificate yet: ask them to send you a signed message. |
The recipient sees an attachment smime.p7s | Their mail program doesn’t do S/MIME; the message itself is still readable. |
| “The signature is not trusted” | The CA’s root is not in that program’s trust store (common with your own CA), or the certificate has expired. |
| Old encrypted mail no longer opens | The old certificate’s private key was deleted. Import the old .p12 again. |
| Webmail can’t read it | Most webmail (Gmail for private accounts, most providers) has no S/MIME. Use a mail program, or webmail that supports it (Outlook on the web, Zimbra, Gmail in Google Workspace Enterprise). |
8. Which one should you use?
- Inside an organisation that hands out certificates (or works with Outlook): S/MIME. It works without plug-ins and the IT department manages it.
- Between individuals, without paying a CA and without expiry dates: OpenPGP.
- Both protect the content, not the metadata. For a conversation instead of an email, a messenger with forward secrecy (Signal, part 4) is a better fit: email has no forward secrecy, so whoever later steals your private key can read every message ever encrypted to it.
Sources
- RFC 8551 (S/MIME 4.0), RFC 5652 (CMS), RFC 5083 (AuthEnvelopedData), RFC 8418 (X25519 in CMS), RFC 8419 (EdDSA in CMS).
- CA/Browser Forum, S/MIME Baseline Requirements.
- Poddebniak et al., Efail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration Channels, USENIX Security 2018.
- Mozilla, Setup your email account for using End-To-End Encryption; Microsoft, Set up Outlook to use S/MIME encryption; Zimbra, Zimbra Daffodil (v10) user guide; GNOME, Evolution: S/MIME.