Chapter 5 of 8

Certificates at the edge

SNI, virtual hosts, chain order, wildcards, multiple listeners and mutual TLS.

About 11 minutes of reading

By the end of this chapter you can

  • Explain how SNI selects a certificate
  • Assemble a correct chain bundle for a server
  • Describe how mutual TLS authenticates clients
  • Identify where a TLS-terminating proxy changes your trust model

01Many names, one address

A server often hosts dozens of sites on one IP address. It cannot know which certificate to present until the client says which name it wants — that is what SNI does during ClientHello. The server then selects a certificate matching that name.

Consequences: an old client without SNI support gets the default certificate and may see a name mismatch; and an observer can see which site you asked for unless ECH is in use.

02Assembling the chain

TLS requires the server to send its leaf certificate and the intermediates that connect it to a root the client trusts. Order matters for some clients: leaf first, then intermediates, then optionally the root (which is usually unnecessary).

cat fullchain.pem | openssl crl2pkcs7 -nocrl -certfile /dev/stdin | openssl pkcs7 -print_certs -noout
# Expect: subject=leaf, then subject=intermediate, each issuer matching the next subject
Check the order and completeness of a bundle

03Wildcards and name coverage

Certificate nameCoversDoes not cover
shop.example.comExactly that namewww.shop.example.com
*.example.comone label, e.g. api.example.comexample.com, a.b.example.com
SAN with several namesEvery listed nameAnything not listed

Wildcards are convenient and dangerous: one key on one server now protects every hostname under the domain, so a single compromise has a wider blast radius.

04Mutual TLS and termination

In mutual TLS (mTLS) the client also presents a certificate. The server validates it against a client trust store. This authenticates devices and services strongly, but it does not authorise them: you still need policy about what that identity may do.

  • mTLS needs a client CA and a distribution mechanism for client certificates
  • Revocation of client certificates matters more than for servers, because they are long-lived
  • A TLS-terminating proxy holds the private key; its configuration, patching and access control are part of your trust boundary
  • With termination, traffic behind the proxy is often plaintext; treat that network segment accordingly

What to remember

  • SNI chooses which certificate a server presents, before encryption begins
  • Send leaf and intermediates in order; omit the root
  • Wildcards cover one label only and widen the blast radius of a leaked key
  • mTLS authenticates clients but does not authorise them, and a terminating proxy becomes part of your trust boundary