When an S/MIME client harvests a correspondent's certificate from an incoming signed message, what does it keep, and when must it refuse?
answer
- certificates field of SignedData
- two signed attributes worth remembering
- newer signing time, valid signature
- which certificate for key management
basics
~20 sIt binds the signer's certificate from the SignedData certificates field to the sender and records the SMIMECapabilities and SMIMEEncryptionKeyPreference attributes, but only once the signature verifies, the certificate validates and the signing time is newer and plausible.
solid answer
~50 sA signed S/MIME message carries certificates in its `SignedData` structure, usually the signer's own and its issuers', in any order. The client caches them for path validation and, once the signature verifies and the certificate validates for the `From` address, binds the signer's certificate to that correspondent. It also reads two signed attributes: `SMIMECapabilities`, a partial list in preference order of algorithms the sender can handle, and `SMIMEEncryptionKeyPreference`, which names the certificate the sender wants replies encrypted to. Under RFC 8551 the stored capabilities are created or replaced only when the signature is valid and the signing time is later than the one stored; a signing time far in the future, or capabilities from a signature that could not be verified, MUST NOT be accepted. With no capabilities known, S/MIME 4.0 tells the sender to fall back to AES-256 GCM.
code
pseudocode · 15 lineson signed message M from address A:
if signature of M does not verify: keep nothing
if signer certificate does not validate: keep nothing
if certificate lists addresses and A is not one of them:
warn user; keep nothing (local policy)
if M.signingTime is beyond reasonable clock skew: ignore its attributes
cache M.certificates for path validation
entry = store[A]
if entry is empty or M.signingTime > entry.signingTime:
entry.signerCert = signer certificate of M
entry.capabilities = M.SMIMECapabilities
entry.encryptionCert = certificate named by M.SMIMEEncryptionKeyPreference
else a stored certificate with the signer's subject name
that allows key management
entry.signingTime = M.signingTimego deeper
Recall that a signed message carries the sender's certificate, and that the client keeps it so the user can encrypt to that sender later.
Explain the two signed attributes a client remembers, SMIMECapabilities and SMIMEEncryptionKeyPreference, and the rule that they update only from a valid, newer signature.
Diagnose replies encrypted to a superseded certificate or a weak cipher by reading what the client stored, when, and from which signed message.
Decide whether staff sign by default so certificates and capabilities reach partners, and how renewals are announced so stored entries move forward.
## What a signed message brings with it An S/MIME signed message is a CMS **`SignedData`** structure. Besides the signature itself, it has a **`certificates`** field. RFC 8550 (section 2.3) says senders SHOULD put their own certificate and the issuer certificates in it, and that receiving clients MUST cope with "an arbitrary number of certificates of arbitrary relationship to the message sender and to each other in arbitrary order". Some may be unrelated to the sender and included only for convenience. Each signer's **`SignerInfo`** also carries **signed attributes**. Two of them matter for later encryption: | Signed attribute | Defined in | What it tells the recipient | |---|---|---| | `SMIMECapabilities` | RFC 8551, 2.5.2 | algorithms the sender can handle, in order of preference; a partial list, not everything supported | | `SMIMEEncryptionKeyPreference` | RFC 8551, 2.5.3 | which of the sender's certificates holds the key the sender wants used for encrypting replies | | `signingTime` | RFC 8551, 2.5.1 | when the signer says it signed; only as trustworthy as the signer | Both S/MIME attributes MUST be signed attributes when present, so they are covered by the signature. ## The two stores: a cache and an address book RFC 8550 separates two uses of what arrives: - **A temporary cache for validation.** Incoming certificates SHOULD be cached for use in path validation and may be stored for later use (section 4.2). This cache helps build chains; it does not by itself say "this certificate belongs to this correspondent". - **A protected per-correspondent store.** Agents SHOULD let users "store and protect" correspondents' certificates for later retrieval (section 4), much like an address book. This is the binding a client consults when the user next writes to that address. Moving a certificate from the first to the second is the step called **harvesting**. ## When harvesting must not happen The defensive rules come from RFC 8551 section 2.7.1 for capabilities and section 2.5.3 for the key preference: 1. **Verify the signature first.** The capabilities list is created only "after verifying the signature on the incoming message and checking the timestamp". 2. **Only move forward in time.** An existing list is replaced only if the incoming signing time is greater than the stored one and the signature is valid; the encryption key preference is stored on the same condition. 3. **Reject implausible clocks.** Signing times "far in the future (that is, a greater discrepancy than any reasonable clock skew)" MUST NOT be accepted. 4. **Never learn from an unverifiable message.** A capabilities list in a message whose signature could not be verified MUST NOT be accepted. Two further checks come from certificate handling rather than the capability rules. The certificate has to validate to a trust anchor the client accepts (covered with certificate path validation), and RFC 8550 section 3 requires the receiving client to check that the `From` or `Sender` address matches a mail address in the signer's certificate when it carries one. Binding a certificate that fails either check to a correspondent would let a forged or mismatched message plant the key future mail is encrypted to. RFC 8550's security considerations add that certificates not yet validated to a trust anchor should be handled with caution, since untrusted sources can manufacture them. ## Choosing the recipient's certificate later When the user replies encrypted, RFC 8551 section 2.5.3.1 gives the order: 1. if an `SMIMEEncryptionKeyPreference` was received from that correspondent, use the certificate it names; 2. otherwise search the stored certificates for one with the signer's subject name that can be used for key management; 3. otherwise use some other method; if no key management certificate is found, encryption to that person cannot be done. The preference exists for correspondents who keep separate signing and encryption certificates (the reasons for splitting them belong to the material on the mailbox certificate profile). ## Choosing the algorithm RFC 8551 section 2.7.1 then picks the content cipher: - **Known capabilities:** use the first capability in the stored list that the sender can produce. - **Unknown capabilities and unknown S/MIME version:** S/MIME 4.0 says use **AES-256 GCM**, or AES-128 CBC if the sender chooses not to. S/MIME 3.2 (RFC 5751) said AES-128, then Triple-DES, in the same situation. Before either rule, the sender must decide whether weak encryption is acceptable at all for the data; that decision overrides the rest. ## What an administrator sees - A correspondent who renews and starts signing with a new certificate replaces the stored entry with the next valid signed message, so asking partners to send one signed message after renewal is a cheap fix for "replies go to the old key". - A user who only ever receives encrypted mail from someone, never signed mail, will have harvested nothing from them.
- Why does RFC 8551 tie updating stored capabilities to a later signing time?So that the stored list only moves forward. Without the rule, an older signed message replayed or delivered late could overwrite a correspondent's current capabilities or key preference with stale ones. The signing time is the signer's own claim, so RFC 8551 also refuses values far beyond reasonable clock skew and anything from a signature that does not verify.
- What should a sender's client do when it has never received capabilities from a recipient?Under S/MIME 4.0, if it knows neither the recipient's capabilities nor their S/MIME version, it SHOULD use AES-256 GCM, or AES-128 CBC if it chooses not to. Before that, it must decide whether weak encryption is acceptable for the data at all; that decision overrides the capability rules.
- Every certificate in a signed message belongs to the sender.
- SMIMECapabilities lists every algorithm the sender's client supports.
- Capabilities from a message with a failed signature are still worth storing.
- The newest message to arrive always replaces the stored capabilities.
- The encryption certificate is always the one that made the signature.
Assumes S/MIME 4.0 (RFC 8551, 2019): with no recipient capabilities known it falls back to AES-256 GCM, where S/MIME 3.2 (RFC 5751) fell back to AES-128 then Triple-DES.