TLS & HTTPS
- Draw the TLS 1.2 and TLS 1.3 handshakes and explain why 1.3 needs one round trip fewer and is safer by default
- Explain certificates, chains of trust, CAs, Certificate Transparency and revocation well enough to debug a broken chain
- Design mTLS for service-to-service traffic and for a bank's partner API, including identity mapping and CA rotation
- Choose TLS termination points (edge, load balancer, gateway, sidecar, app) for a PCI-scoped payment flow
- Argue for or against certificate pinning in a mobile banking app, with a rotation plan
TL;DR
- TLS provides confidentiality, integrity and server (optionally client) authentication on top of TCP. HTTPS = HTTP over TLS.
- TLS 1.3 (RFC 8446): 1-RTT handshake, forward secrecy always (ephemeral ECDHE only), only AEAD ciphers, certificate encrypted, legacy features removed. TLS 1.2: 2-RTT full handshake, many unsafe options that must be configured away. Use 1.3, allow 1.2 for compatibility, disable everything older.
- Trust flows root CA → intermediate CA → leaf certificate. Servers must send the leaf and intermediates; clients have the roots. A missing intermediate works in some browsers and fails in Go, Java and mobile clients.
- SNI tells the server which hostname the client wants, in cleartext (until Encrypted Client Hello is widespread). It enables many certificates per IP and SNI-based L4 routing.
- mTLS makes the client present a certificate too. It is the standard for service mesh identity and common for bank partner APIs, combined with OAuth 2.0 (certificate-bound tokens).
- Certificates expire — and lifetimes are shrinking. Automate issuance and rotation (ACME, cert-manager, Vault), hot-reload without restarts, and alert on expiry. Expired certificates are one of the most common self-inflicted outages.
- HSTS forces HTTPS in browsers; pinning in mobile apps blocks MITM but can brick the app on key rotation. Pin public keys, keep backup pins, and plan rotation with app release cycles.
Why it matters
Every bank and e-commerce system relies on TLS in three places: the public edge (browsers and mobile apps), internal service-to-service calls, and partner connections (card schemes, national payment switches, credit bureaus, logistics providers). Each has different failure modes:
- Compliance. PCI DSS requires strong cryptography for cardholder data over open, public networks and has prohibited SSL and early TLS for years. Bank security standards usually extend this to internal traffic (zero trust): data must be encrypted in transit inside the data center too.
- Outages. Expired certificates have caused major incidents — for example, the Ericsson software certificate expiry that disrupted mobile networks (including O2 UK) in December 2018, and the expiry of the old Let's Encrypt root (DST Root CA X3) in 2021 that broke older clients. In a bank, an expired partner certificate stops a payment rail.
- Latency. On a 150 ms mobile RTT, TLS 1.2's extra round trip costs 150 ms on every new connection; TLS 1.3 and resumption claw that back.
- Fraud and security. Mobile banking apps are attacked with interception proxies; pinning and attestation are part of the defense.
Core concepts
What the handshake achieves
- Negotiate protocol version, cipher suite, key exchange group, and ALPN (
h2,http/1.1). - Authenticate the server (and optionally the client) with certificates and a signature proving possession of the private key.
- Agree on keys with ephemeral (EC)DHE so that a later compromise of the server's private key does not decrypt recorded traffic (forward secrecy).
- Confirm that nobody tampered with the negotiation (
Finishedmessages contain a MAC over the whole transcript).
TLS 1.2 handshake (ECDHE)
TLS 1.2 problems you must configure away: static RSA key exchange (no forward secrecy), CBC-mode ciphers (padding-oracle attacks such as Lucky13), RC4, SHA-1, compression (CRIME), insecure renegotiation. A hardened TLS 1.2 config allows only ECDHE with AES-GCM or ChaCha20-Poly1305.
TLS 1.3 handshake
The client guesses the key exchange group and sends its key share in the first message, so keys are ready after one round trip. If the guess is wrong, the server sends a HelloRetryRequest and the handshake takes an extra RTT.
| TLS 1.2 | TLS 1.3 | |
|---|---|---|
| Full handshake | 2 RTT | 1 RTT |
| Resumption | 1 RTT (session ID or ticket) | 1 RTT, or 0 RTT with early data (replayable) |
| Key exchange | RSA or (EC)DHE | (EC)DHE only — forward secrecy always |
| Ciphers | Many, including weak ones | 5 AEAD suites (AES-GCM, ChaCha20-Poly1305, AES-CCM) |
| Certificate visible on the wire | Yes | No (encrypted) |
| Renegotiation, compression | Supported (and attacked) | Removed |
| Downgrade protection | Weaker | Built into the server random |
Post-quantum key exchange. Major browsers, CDNs and recent Go versions already negotiate a hybrid X25519 + ML-KEM key exchange by default. The motivation is "harvest now, decrypt later": recorded traffic could be decrypted by a future quantum computer. For banks with long data-confidentiality horizons, crypto agility (being able to change algorithms through configuration rather than code rewrites) is becoming an architecture requirement.
Certificates and the chain of trust
An X.509 certificate binds a public key to an identity, signed by an issuer. Key fields:
| Field | Meaning |
|---|---|
| Subject / Subject Alternative Name (SAN) | The identities covered: DNS names, IPs, URIs (SPIFFE IDs). Clients match hostnames against SAN; the CN is legacy |
| Issuer | Who signed it |
Validity (notBefore, notAfter) | Clock skew on clients makes valid certs look "not yet valid" |
| Public key | RSA or ECDSA (P-256 is the common modern choice) |
| Key Usage / Extended Key Usage | serverAuth, clientAuth — a server cert may be rejected as a client cert and vice versa |
| Basic Constraints | CA:TRUE only for CA certificates |
| SCTs | Proof the cert was logged in Certificate Transparency |
Verification steps a client performs: build a path from the leaf to a trusted root; check every signature; check validity dates; check the hostname against SAN; check key usage; check revocation where enforced; check Certificate Transparency where enforced (browsers require it for publicly trusted certificates).
Certificate Authorities:
- Public CAs (DigiCert, Sectigo, Let's Encrypt, Google Trust Services…) are trusted by browsers and operating systems. They verify domain control (DV) or, for higher-assurance products, organization identity (OV/EV). ACME (RFC 8555) automates issuance.
- Private CAs (HashiCorp Vault PKI, AWS Private CA, step-ca, an on-prem enterprise PKI, often HSM-backed) issue certificates for internal services and mTLS clients. Only your systems trust them.
- CAA DNS records restrict which CAs may issue for your domain — cheap protection for a bank's brand domains.
- Certificate Transparency logs make every publicly trusted certificate visible. Banks monitor CT logs for look-alike domains used in phishing and for mis-issued certificates for their own names.
Revocation is the weak spot of web PKI. CRLs are large; online OCSP checks leak browsing data and are often soft-fail; OCSP stapling lets the server attach a fresh signed status. Browsers mostly rely on their own pushed revocation lists, and some CAs have dropped OCSP in favor of CRLs. The industry answer is shorter certificate lifetimes: a CA/Browser Forum decision in 2025 phases the maximum public certificate lifetime down from 398 days to 200 days (2026), 100 days (2027) and 47 days (2029). Manual renewal is no longer viable.
SNI and ALPN
- SNI (Server Name Indication) is a ClientHello extension carrying the hostname. It lets one IP serve many certificates (essential for CDNs and multi-tenant load balancers) and lets L4 proxies route TLS by hostname without decrypting (SNI passthrough). SNI is visible to anyone on the path; Encrypted Client Hello (ECH) hides it and is being deployed by some browsers and CDNs.
- ALPN negotiates the application protocol inside the handshake (
h2,http/1.1), so HTTP/2 needs no extra round trip. gRPC requiresh2.
Debugging tip: openssl s_client does not always send SNI the way a browser does — pass -servername explicitly, or you may get the default certificate and a misleading hostname mismatch.
Session resumption
A full handshake costs CPU (signatures, key exchange) and RTTs. Resumption reuses secrets from a previous session.
| Mechanism | How | Operational concern |
|---|---|---|
| TLS 1.2 session IDs | Server caches session state by ID | Cache must be shared across the LB fleet, or resumption only works on the same node |
| TLS 1.2 session tickets (RFC 5077) | Server encrypts state into a ticket the client stores | Ticket encryption keys must be shared across nodes and rotated — a long-lived ticket key undermines forward secrecy |
| TLS 1.3 PSK resumption | Server sends NewSessionTicket after the handshake; client resumes with a pre-shared key, usually combined with a fresh ECDHE | Good default; still rotate ticket keys |
| TLS 1.3 0-RTT early data | Client sends application data with the resumption attempt | Replayable: only for idempotent, safe requests; reply 425 Too Early otherwise |
For service-to-service traffic, connection pooling matters more than resumption: a warm pooled connection skips TLS entirely.
mTLS: mutual authentication
In mTLS the server sends a CertificateRequest and the client answers with its own certificate and a CertificateVerify signature. The server validates the client chain against a client CA pool and maps the certificate identity to a principal.
Service-to-service (service mesh). Istio and Linkerd issue each workload a short-lived certificate (on the order of a day by default) with a SPIFFE identity such as spiffe://bank.example/ns/payments/sa/transfer-api in the SAN URI. Sidecars or node proxies perform mTLS transparently and rotate certificates automatically; authorization policies then say "only transfer-api may call ledger". This is the backbone of zero-trust networking — see Security for Architects.
Bank partner APIs. A typical partner integration (fintech, merchant aggregator, another bank, a card scheme gateway):
Design points:
- Two layers of identity: the TLS client certificate proves which partner system is connecting; the OAuth 2.0 token carries scopes and consent. Certificate-bound access tokens (RFC 8705) make a stolen token useless without the private key. Financial-grade API profiles (FAPI) require this kind of sender-constrained token. In the EU, PSD2 open banking identifies third-party providers with eIDAS qualified certificates over mTLS.
- Allowlist by certificate identity, not just by "signed by a CA I trust" — otherwise any certificate the CA ever issued can call you.
- IP allowlisting is often required in addition (see OSI & TCP/IP Models).
- Where mTLS terminates: if the gateway terminates it, the backend must trust a header like
X-Client-Cert-Subjectonly from the gateway, over its own mTLS. - Keys in HSMs: banks often keep private keys for partner-facing certificates in HSMs or cloud KMS-backed key stores so they cannot be exfiltrated.
Certificate rotation
Rotation is where outages happen. A reliable process:
- Automate issuance (ACME for public certs; cert-manager, Vault agent or SPIRE for internal ones). Renew at roughly two-thirds of the lifetime.
- Hot-reload certificates without restarts (the Go example below), or roll pods gradually.
- Monitor expiry of every endpoint you serve and every partner endpoint you call: alert at 30, 14 and 7 days. Include certificates baked into clients, HSMs, load balancers and CDNs.
- Rotating a CA (e.g. the partner client CA): publish a trust bundle containing old and new CA, wait until all verifiers have it, then start issuing from the new CA, then remove the old CA after the last old certificate expires.
- Coordinate with partners months ahead; banks often have change windows and manual processes for importing certificates.
TLS termination points
| Option | What sees plaintext | Strengths | Weaknesses |
|---|---|---|---|
| Terminate at CDN/edge only, HTTP to origin | CDN and everything after it | Simplest, fastest | Plaintext inside your network; fails most bank security policies and PCI expectations for card data |
| Terminate at edge, re-encrypt to origin | Each proxy hop briefly | Edge can cache, WAF can inspect; still encrypted in transit | More certificates to manage, extra CPU per hop |
| TLS passthrough (L4, SNI routing) to the app | Only the app | End-to-end confidentiality; app holds the key | No WAF, no L7 routing or caching in between; app handles all TLS |
| Terminate at gateway + mesh mTLS internally | Gateway and each service's sidecar | Strong service identity, policy, automatic rotation | Mesh operational complexity |
| Terminate in the app itself | Only the app | Fewest trusted parties | Every service manages certs; hard to standardize |
For card data, many designs add application-level encryption or tokenization on top of TLS so that intermediaries (CDN, WAF, logging) never see a raw card number — see Payments & Card Flows.
HSTS
HTTP Strict Transport Security tells a browser to use only HTTPS for a domain for a period of time:
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
- Defeats SSL stripping, where an attacker on public Wi-Fi intercepts the first plain-HTTP request and keeps the victim on HTTP.
- The first visit is still vulnerable unless the domain is on the browser preload list (requires a long
max-age,includeSubDomainsandpreload). includeSubDomainsbreaks any subdomain that still serves plain HTTP (an old intranet tool, a printer). Removing a domain from the preload list takes months — roll out with a shortmax-agefirst.
Certificate pinning in mobile banking apps
Pinning means the app accepts only specific keys or certificates for your API, not any certificate chaining to a trusted root.
| Without pinning | With pinning | |
|---|---|---|
| Rogue or mis-issued CA certificate for your domain | Accepted | Rejected |
| User-installed MITM proxy CA (malware, corporate proxy, attacker on a rooted phone) | Accepted on Android only if the app opts in to user CAs; accepted on iOS if the user trusts the profile | Rejected |
| Key/CA rotation | Transparent | Must ship new pins before rotation — or the app stops working |
| Reverse engineering on a rooted/jailbroken device | Easy | Still possible (hooking frameworks bypass pinning); raises the bar |
Guidelines if you pin (common in banking apps, and referenced by OWASP MASVS):
- Pin the public key (SPKI hash), not the certificate, so renewing a certificate with the same key does not break the app.
- Pin your intermediate CA or your own long-lived keys, and always include at least one backup pin for a key you hold offline.
- Use platform mechanisms where possible: Android Network Security Config
pin-set(with an expiration date), iOSNSPinnedDomains. - Plan rotation around the app release cycle: ship the new pin in a release months before the server key changes, and enforce a minimum app version.
- Report pin failures to monitoring; a spike means rotation trouble or an attack.
- Pinning is one layer: combine it with device attestation, root/jailbreak detection, and server-side fraud signals.
The argument against pinning: CT monitoring plus short-lived certificates already reduce mis-issuance risk, and a pinning mistake is a self-inflicted outage for every customer at once. For high-value banking apps, most teams still pin, carefully.
Trade-offs
| Option | Strengths | Weaknesses | Choose when |
|---|---|---|---|
| TLS 1.3 only | Fastest, safest defaults | Breaks old clients, some legacy partner stacks | Internal services, modern mobile apps |
| TLS 1.2 + 1.3 | Broad compatibility | Must harden 1.2 cipher list | Public edge, partner APIs |
| Public CA certs everywhere | Trusted by every client | Lifetime limits, CT exposure of internal hostnames | Internet-facing endpoints |
| Private CA for internal / mTLS | Full control, short lifetimes, internal names stay private | You run a PKI (HSM, CRLs, rotation) | Service mesh, partner client certs |
| mTLS | Strong client identity, no shared secrets | Certificate lifecycle with every client; harder debugging | Service-to-service, bank partner APIs |
| OAuth tokens over plain TLS | Easy for partners | Bearer tokens can be replayed if stolen | Low-risk partner APIs, public developer APIs |
| Session tickets / 0-RTT | Lower latency on reconnect | Ticket key management; 0-RTT replay | Public, idempotent content at the edge |
| Certificate pinning | Blocks MITM with rogue/user CAs | Rotation risk, can brick the app | High-value mobile banking apps, with backup pins |
In practice
mTLS server in Go with hot-reloaded certificates. cert-manager, Vault agent or SPIRE rewrites the files; the server picks them up without a restart. The client CA file can contain old and new CAs during a rotation.
package main
import (
"crypto/tls"
"crypto/x509"
"log"
"net/http"
"os"
"sync"
"time"
)
// certReloader serves the most recently loaded certificate.
type certReloader struct {
certFile, keyFile string
mu sync.RWMutex
cert *tls.Certificate
}
func (r *certReloader) load() error {
c, err := tls.LoadX509KeyPair(r.certFile, r.keyFile)
if err != nil {
return err
}
r.mu.Lock()
r.cert = &c
r.mu.Unlock()
return nil
}
func (r *certReloader) getCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error) {
r.mu.RLock()
defer r.mu.RUnlock()
return r.cert, nil
}
func main() {
reloader := &certReloader{certFile: "server.crt", keyFile: "server.key"}
if err := reloader.load(); err != nil {
log.Fatal(err)
}
go func() {
for range time.Tick(time.Minute) {
if err := reloader.load(); err != nil {
log.Printf("certificate reload failed, keeping previous: %v", err)
}
}
}()
caPEM, err := os.ReadFile("partners-ca.pem")
if err != nil {
log.Fatal(err)
}
clientCAs := x509.NewCertPool()
if !clientCAs.AppendCertsFromPEM(caPEM) {
log.Fatal("no CA certificates found in partners-ca.pem")
}
srv := &http.Server{
Addr: ":8443",
Handler: http.HandlerFunc(handle),
ReadHeaderTimeout: 5 * time.Second,
TLSConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
GetCertificate: reloader.getCertificate,
ClientAuth: tls.RequireAndVerifyClientCert,
ClientCAs: clientCAs,
},
}
log.Fatal(srv.ListenAndServeTLS("", ""))
}
// allowedPartners maps verified certificate identities to partner IDs.
var allowedPartners = map[string]string{
"partner-acme": "P-1001",
}
func handle(w http.ResponseWriter, r *http.Request) {
leaf := r.TLS.PeerCertificates[0] // verified by the TLS layer
partnerID, ok := allowedPartners[leaf.Subject.CommonName]
if !ok {
http.Error(w, "unknown client certificate", http.StatusForbidden)
return
}
log.Printf("partner=%s serial=%s expires=%s", partnerID, leaf.SerialNumber, leaf.NotAfter.Format(time.RFC3339))
w.WriteHeader(http.StatusNoContent)
}
The matching client sets tls.Config{Certificates: []tls.Certificate{clientCert}, RootCAs: bankCAPool, MinVersion: tls.VersionTLS12} on its http.Transport. In Go, TLS 1.3 cipher suites are not configurable (all are safe), and TLS 1.2 defaults are already restricted to modern suites.
Operational checklist:
- Inventory every certificate: public edge, internal CAs, partner client certs, certs inside HSMs, load balancers and CDNs. Expiry monitoring for all of them.
- Use ECDSA P-256 keys where clients allow it (smaller, faster handshakes); keep RSA 2048+ where legacy partners require it.
- Send the full chain (leaf + intermediates) and test with a strict client (
openssl s_client, Go, Java), not just a browser. - Keep clocks synchronized (NTP); skewed clocks break validation.
- Log certificate serial, subject and expiry of client certs on each partner connection for audit.
Common pitfalls
- Expired certificate. Symptom: sudden total failure of an integration or website at a specific minute;
x509: certificate has expired or is not yet valid. - Missing intermediate. Symptom: works in Chrome (which can fetch or cache intermediates) but fails in Go/Java/curl and mobile apps with
unknown authority/unable to get local issuer certificate. - SAN mismatch. Symptom:
certificate is valid for a.example, not b.exampleafter adding a new hostname or calling a service by IP. - Wrong EKU. Symptom: a server certificate reused as a client certificate is rejected in mTLS.
- CA rotated without a trust-bundle overlap. Symptom: half the fleet rejects the other half during rollout.
- Session ticket keys never rotated (or not shared). Symptom: either weak forward secrecy, or resumption only working on one node and higher CPU on the LB fleet.
InsecureSkipVerify: trueleft in client code "temporarily". Symptom: no visible symptom — that is the problem; a MITM goes unnoticed. Grep for it in CI.- Pinning the leaf certificate with no backup pin. Symptom: after a routine renewal, every installed app version fails to connect.
- HSTS
includeSubDomainsrolled out with a longmax-ageon day one. Symptom: internal HTTP-only subdomains become unreachable from browsers. - Trusting
X-Client-Certheaders from anywhere. Symptom: an attacker who can reach the backend directly spoofs a partner identity.
Interview angle
- "Walk me through the TLS handshake." Draw TLS 1.3 (ClientHello with key share, ServerHello, encrypted certificate and Finished), state 1 RTT vs 2 RTT for 1.2, forward secrecy, and where the certificate is verified.
- "How do you secure service-to-service calls?" mTLS with workload identities (SPIFFE), short-lived certs issued by a private CA, automatic rotation by a mesh or agent, plus authorization policies on identities.
- "Design a partner API for fintechs to initiate payments." mTLS for client authentication, OAuth 2.0 client credentials with certificate-bound tokens, idempotency keys, per-partner quotas, IP allowlisting, audit logs of certificate identity, and a CA rotation plan.
- "Where do you terminate TLS?" Edge for WAF/caching with re-encryption inward, mesh mTLS inside, tokenization for card data — and explain what each hop can see.
- Follow-ups: what forward secrecy means, why 0-RTT is dangerous, OCSP stapling vs short-lived certs, how pinning can backfire.
- Red flags: "TLS encrypts with the server's private key", not knowing that the server must send intermediates,
InsecureSkipVerifyas a fix, or proposing pinning without a rotation plan.
Self-check
1. Why does TLS 1.3 complete in one round trip while TLS 1.2 needs two?
In TLS 1.3 the client sends its ephemeral key share in the ClientHello, guessing the group. The server replies with its key share and can immediately derive keys and send its certificate, signature and Finished encrypted. In TLS 1.2 the key exchange parameters are only sent after the cipher suite is chosen, so client key exchange happens in a second flight.
2. A Go service fails to call a partner with “x509: certificate signed by unknown authority”, but the URL opens fine in Chrome. What is the likely cause and how do you confirm it?
The partner's server is probably not sending its intermediate certificate. Chrome can complete the chain using cached or fetched intermediates; Go only uses what the server sends plus its root store. Confirm with openssl s_client -connect host:443 -servername host -showcerts and check whether only the leaf is returned. The fix belongs on the partner's server (send the full chain); as a stopgap you could add the intermediate to your client's pool.
3. What is forward secrecy and which TLS feature provides it?
Forward secrecy means that compromising the server's long-term private key later does not let an attacker decrypt previously recorded sessions. It comes from ephemeral (EC)DHE key exchange: each session's keys derive from throwaway key pairs that are discarded. TLS 1.3 mandates it; TLS 1.2 provides it only if you disable static RSA key exchange — and long-lived session ticket keys can weaken it.
4. How would you rotate the CA that signs partner client certificates without downtime?
Create the new CA. Distribute a trust bundle containing both old and new CA to all verifiers (gateways) and confirm rollout. Issue new client certificates from the new CA and coordinate partners switching to them. Monitor which CA signs each connecting cert. Once no connections use old-CA certificates (or they expire), remove the old CA from the bundle. Never switch the bundle and the issuance at the same time.
5. Why bind OAuth access tokens to the client certificate in a partner API?
A bearer token can be used by anyone who steals it (logs, compromised partner proxy). With certificate-bound tokens (RFC 8705), the token contains the thumbprint of the client certificate, and the resource server checks it matches the certificate presented on the mTLS connection. A stolen token is useless without the private key.
6. Your security team wants TLS passthrough all the way to the payment service. What do you lose and what alternatives keep most of the benefit?
With passthrough, intermediate proxies cannot inspect requests, so you lose WAF protection, L7 routing, rate limiting by path or identity, caching and request-level observability at the edge, and the app must handle all TLS concerns. Alternatives: terminate at the edge/gateway and re-encrypt (TLS or mTLS) to the service, and protect the most sensitive fields with application-level encryption or tokenization so intermediaries never see them in clear.
7. List three rules for certificate pinning in a mobile banking app.
Pin SPKI hashes (public keys), not whole certificates. Pin an intermediate or your own keys and always ship at least one backup pin held offline. Tie rotations to the app release cycle (ship new pins well before changing keys, enforce minimum app versions) and report pin-validation failures to monitoring.
8. What does HSTS protect against, and what is the risk of includeSubDomains; preload?
HSTS stops SSL-stripping attacks by making the browser refuse plain HTTP for the domain, and preload protects even the first visit. With includeSubDomains every subdomain must serve HTTPS, so legacy HTTP-only hosts break; preload removal takes months, so a mistake is long-lived. Roll out with a short max-age, audit subdomains, then extend.
Exercise
Part A — inspect real handshakes.
# Negotiated version, cipher, chain and ALPN
openssl s_client -connect www.google.com:443 -servername www.google.com -alpn h2,http/1.1 -showcerts </dev/null 2>/dev/null | grep -E 'Protocol|Cipher|ALPN|s:|i:'
# Expiry and SAN of a site's leaf certificate
echo | openssl s_client -connect www.google.com:443 -servername www.google.com 2>/dev/null \
| openssl x509 -noout -subject -issuer -dates -ext subjectAltName
# Force TLS 1.2 and compare
openssl s_client -connect www.google.com:443 -servername www.google.com -tls1_2 </dev/null 2>/dev/null | grep -E 'Protocol|Cipher'
Part B — build an mTLS partner API locally (OpenSSL 3.x; on macOS install it with Homebrew rather than using the bundled LibreSSL):
# Private CA
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
-keyout ca.key -out ca.crt -days 30 -subj "/CN=Handbook Test CA"
# Server certificate for localhost
openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
-keyout server.key -out server.csr -subj "/CN=localhost"
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
-out server.crt -days 7 -extfile <(printf "subjectAltName=DNS:localhost,IP:127.0.0.1")
# Client certificate for a partner
openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
-keyout partner.key -out partner.csr -subj "/CN=partner-acme"
openssl x509 -req -in partner.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
-out partner.crt -days 7 -extfile <(printf "extendedKeyUsage=clientAuth")
cp ca.crt partners-ca.pem
Run the Go server from this page, then:
curl --cacert ca.crt --cert partner.crt --key partner.key -i https://localhost:8443/ # 204
curl --cacert ca.crt -i https://localhost:8443/ # handshake fails
Now rotate: issue a new server certificate, overwrite server.crt/server.key, wait a minute, and confirm with openssl s_client that the new serial is served without restarting. Finally, create a second CA, issue a client cert from it, and practice the old+new trust-bundle rotation.
Done when: you can show the TLS 1.3 vs 1.2 difference from real output, your mTLS server rejects clients without a certificate and with an unknown identity, and certificate rotation happens with zero failed requests (run a while true; do curl ...; done loop during rotation).
Further reading
- Bulletproof TLS and PKI (2nd ed.) — Ivan Ristić.
- RFC 8446 — The Transport Layer Security (TLS) Protocol Version 1.3.
- RFC 8705 — OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens.
- RFC 6797 — HTTP Strict Transport Security.
- The Illustrated TLS 1.3 Connection — byte-by-byte walkthrough by Michael Driscoll.
- OWASP Mobile Application Security (MASVS / MASTG) — network communication and pinning guidance.
- SPIFFE / SPIRE documentation — workload identity for mTLS.
Related
- HTTP/1.1, HTTP/2, HTTP/3 — ALPN, QUIC's built-in TLS 1.3, 0-RTT.
- Proxies, Load Balancers & API Gateways — where termination and re-encryption happen.
- Security for Architects — zero trust, secrets, key management.
- Compliance: PCI DSS, KYC/AML, Data Protection — encryption-in-transit requirements.
- Payments & Card Flows — tokenization on top of TLS.
- Network Troubleshooting — debugging handshakes in production.
- Microservices Patterns — service mesh and gateway patterns.
Do the self-check first. Marking it complete schedules spaced reviews (1, 3, 7, 14, 30… days).