S/MIME signatures

Bongo checks the S/MIME signature of a message when you open it and shows a badge above the body. It does not sign, encrypt or decrypt anything.

What the badge says

Badge Meaning
Signed by name <address> The signature covers the signed part of the message, the signer’s certificate chains to a root in the server’s system trust store, is valid now, when you open the message, and names the address in the From header.
Signature not valid, with a reason The message is signed but one of those checks failed. The reasons are: the message does not match its signature, the certificate is not trusted, the certificate is expired or not yet valid, the certificate does not name the sender address, or the signature cannot be checked (an unsupported algorithm or structure, or a size limit).
Encrypted message; open it in a mail client that holds your key The message is an application/pkcs7-mime object (encrypted, or signed in the opaque form). Bongo never holds your key and does not open it. The smime.p7m part stays listed so you can save it.

A signed message’s smime.p7s part is not listed as an attachment while the badge is shown. It is still reachable by its index, and the other attachments keep their links.

“Signed by” is not DMARC and not proof of identity. It means only that a certificate from a root your server trusts names the From address. Only the address is checked: the name shown before it is whatever the signer put in the certificate. The signature covers the signed part (the body and its attachments), not the outer headers, so the Subject, the display name in From and the Date can be changed without the badge changing. Revocation is not checked: a certificate that was revoked after it was issued still verifies, and the badge says so.

How it is checked

  • The signature is checked against the signed part exactly as stored, with line ends turned into CRLF, which is what S/MIME signs. Stored copies that lost their carriage returns still verify.
  • Certificate validity is judged when the message is shown, not at the signing time the sender wrote into the signature and not at the message’s Date header, which the sender chooses. A signature from a certificate that has expired since the message arrived therefore shows as expired, as it does in most mail clients.
  • The signer must have one signature, use SHA-256, SHA-384 or SHA-512, be allowed to sign mail (extended key usage email protection, or none) and name the From address in its subject alternative name. The subject email address is never used: name constraints on a CA apply to subject alternative names only, so a CA limited to one domain could otherwise sign for any address. A certificate that names the address only in its subject reads as “does not name the sender address”. Addresses are compared with ASCII letters folded to one case and every other character exact. Every intermediate in the chain must allow email protection too (or carry no extended key usage), so a CA limited to TLS does not vouch for mail; the wrong usage reads as “not trusted”. A message with several From addresses, or with more than one From field in its header, never matches.
  • The signature part must be base64, which is what mail clients send, and hold exactly one BER object (a SEQUENCE) with nothing after it. Definite and indefinite lengths are both read, because Thunderbird sends the outer levels of its signatures with indefinite lengths. A signature in another transfer encoding, with trailing bytes, nested more than 32 levels deep, holding more than 32,768 elements or otherwise malformed reads as “cannot be checked”; this is checked in one pass before the signature is parsed.
  • The certificate name shown is certificate text from the sender: control characters and every angle bracket and at sign (and their look-alikes) are removed, so it cannot read as an address, and it is cut at 128 characters. A certificate with no name shows the address alone.

Limits and what is not done

  • Bounded: a message over 32 MiB, a signature part over 256 KiB, more than 16 embedded certificates, a chain longer than 6, or a check that takes more than one second is reported as “cannot be checked”. At most four checks run at once on a node.
  • No network: nothing is fetched (no AIA, OCSP or CRL). On Linux, the only release platform, Go never does this while verifying. On macOS and Windows development builds the system’s own verifier may.
  • Only a signature at the top level of the message is checked. A signed message forwarded inside another message, or wrapped by a mailing list in another multipart, shows no badge.
  • Thread siblings shown under a message get no badge, so opening a long thread costs one check, not one per message.
  • Shared folders show the same badge to anyone who can read the message.
  • Nothing is cached or stored, so there is no new key or command and nothing to upgrade in a cluster; a node without this feature simply shows no badge. A change to the system trust store applies to the next view.
  • The trust store is the server’s system store. There is no setting to add a root. The system store does not separate roots trusted for TLS from roots trusted for S/MIME: any root it holds can vouch for a mail signature, as long as the chain below it allows email protection.
  • An attachment policy that removes a part changes the message, so a signature on it no longer verifies and shows “does not match its signature”.

Boundary checks

The verifier hashes the raw bytes of the first part, while the page shows the body from the MIME parser. To keep the two in agreement, a signed message is refused (shown as “cannot be checked”) when:

  • the header of the message, or of the signature part, has a line without a colon (Go’s parser stops there while the MIME parser folds the line into the field before);
  • the Content-Type header of the message appears more than once, contains an encoded word (=?), or reads as a different type or boundary to the MIME parser than to the verifier (the parser repairs and decodes some malformed headers);
  • the signature part names a boundary or, as parsed, has parts of its own: the MIME parser treats any part with a boundary as a multipart, so parts after the signature bytes would be shown though the signature does not cover them;
  • any part, attachment or inline part the page could show lies outside the signed first part, other than the signature itself;
  • any line other than the three delimiter lines contains the boundary string, in the preamble, between the parts or in the epilogue;
  • the second part is not a pkcs7-signature, or the parsed message does not have exactly two parts;
  • the first part the MIME parser shows, split again on the boundary it used, is not byte for byte the part whose signature was checked.

The badge shows the certificate address that matched From next to the name, because the name is chosen by the sender.

View this page's source on GitHub