TLS 1.3 handshake, certificate chains, and HTTPS internals
How HTTPS combines asymmetric and symmetric encryption, why TLS 1.3 cuts handshakes to 1-RTT with mandatory PFS, and how to debug X.509 chains with OpenSSL.
HTTPS pairs asymmetric and symmetric cryptography to solve key distribution, server authentication, and bulk throughput at the same time. This post covers the TLS 1.3 1-RTT handshake and mandatory PFS, how X.509 certificate chains and SNI work, and how I diagnose TLS failures in production with
openssl.
Reference environment: RFC 8446 (TLS 1.3), RFC 5280 (X.509 PKI), OpenSSL 3.x / Java 21
Why HTTPS combines asymmetric and symmetric encryption
Symmetric ciphers such as AES-GCM and ChaCha20-Poly1305 use a single shared secret for both encryption and decryption. With CPU hardware acceleration (like AES-NI), they encrypt gigabytes of HTTP traffic per second with minimal overhead. The catch is the key distribution problem: two hosts meeting for the first time over an untrusted network can’t safely hand each other that shared secret in plaintext.
Asymmetric cryptography (RSA, ECDSA, ECDHE) solves key exchange and identity verification using a public/private key pair, but its math is orders of magnitude slower than symmetric encryption. Running every HTTP payload through asymmetric operations would burn through server CPU under modest traffic.
HTTPS uses a hybrid design to get the best of both worlds. During the handshake, the client and server use asymmetric cryptography to verify the server’s identity and agree on ephemeral session keys. Once the handshake finishes, every HTTP header and body byte travels over an AEAD (Authenticated Encryption with Associated Data) symmetric cipher, which guarantees both confidentiality and integrity.
TLS 1.2 vs. TLS 1.3 handshakes
In TLS 1.2, cipher suite negotiation and key exchange happened in separate round trips, adding 2-RTT on top of the TCP 3-way handshake. TLS 1.2 also allowed static RSA key exchange. With static RSA, an attacker who records encrypted traffic today and steals the server’s private key months later can decrypt all past sessions—meaning Perfect Forward Secrecy (PFS) wasn’t guaranteed. Legacy algorithms like CBC mode, SHA-1, and RC4 also lingered in TLS 1.2 cipher lists.
TLS 1.3 (RFC 8446) stripped away those legacy paths and redesigned the handshake from the ground up.
sequenceDiagram
participant C as Client
participant S as Server
C->>S: ClientHello + key_share + SNI
Note over S: Derive ECDHE session key & encrypt cert
S-->>C: ServerHello + key_share + Encrypted Cert + Finished
Note over C: Verify cert chain & derive session key
C->>S: Finished + Encrypted HTTP request (1-RTT)
S-->>C: Encrypted HTTP response (AEAD)
Three changes make the biggest practical difference:
- 1-RTT handshake: The client includes an ephemeral public key (
key_share, usuallyx25519) right inside the initialClientHello. The server derives the shared session key immediately and sends backServerHello, its ownkey_share, the encrypted certificate chain, andFinishedin a single flight. - Mandatory PFS: Static RSA key exchange is gone. Every session uses ephemeral ECDHE or DHE keys that are discarded after the session ends, so a leaked long-term server private key can’t decrypt recorded traffic.
- Minimal AEAD cipher suites: TLS 1.3 narrows the list to five audited AEAD suites (such as
TLS_AES_256_GCM_SHA384andTLS_CHACHA20_POLY1305_SHA256) and encrypts everything afterServerHello, including the server certificate.
| Aspect | TLS 1.2 | TLS 1.3 (RFC 8446) |
|---|---|---|
| Initial handshake | 2-RTT | 1-RTT (with key_share) |
| Session resumption | 1-RTT | 0-RTT (PSK Early Data) |
| Key exchange | RSA / DHE / ECDHE | ECDHE / DHE only |
| Perfect Forward Secrecy (PFS) | Optional (broken with static RSA) | Mandatory |
| Cipher suites | Dozens (includes weak legacy ciphers) | 5 standard AEAD suites |
| Certificate transmission | Plaintext | Encrypted after ServerHello |
When not to enable TLS 1.3 0-RTT: 0-RTT resumption lets a returning client send application data in the very first packet using a pre-shared key (PSK), cutting latency even further. However, 0-RTT early data isn’t protected against replay attacks. If an attacker captures and replays that first packet, the server executes it twice. I leave 0-RTT disabled on state-changing endpoints (POST, PUT, DELETE) and only consider it for strictly idempotent GET traffic at the edge.
X.509 certificate chains and SNI
Encryption alone doesn’t stop a man-in-the-middle attack if you’re encrypting traffic with an attacker’s public key. The X.509 PKI Chain of Trust lets the client confirm that the server actually owns the target domain.
Operating systems, browsers, and the JDK ship with a small trust store of Root CA certificates. During the handshake, the server presents a signed chain: Root CA -> Intermediate CA -> Leaf (server) certificate. The client verifies the leaf certificate’s signature with the intermediate CA’s public key, verifies the intermediate CA’s signature against a trusted Root CA in its local store, and checks both the validity window and the SAN (Subject Alternative Name) extension against the requested hostname.
CAs don’t sign leaf certificates directly with their Root CA for blast-radius isolation. A Root CA’s private key stays offline in an HSM (Hardware Security Module), while Intermediate CAs handle day-to-day issuance. If an Intermediate CA is ever compromised, CAs revoke that intermediate without forcing every OS and browser vendor worldwide to push an emergency root-store update.
One subtle problem shows up when multiple HTTPS domains share a single public IP on port 443. The HTTP Host header is encrypted until the TLS handshake completes, so the server doesn’t know which domain’s certificate to present. SNI (Server Name Indication) solves this by putting the target hostname in a plaintext extension inside ClientHello, letting the reverse proxy or load balancer pick the right certificate chain before responding.
Debugging TLS 1.3 and certificate chains with OpenSSL
Whenever a client fails to connect over HTTPS, I start with openssl s_client to see the exact protocol version and certificate chain the server sends. On multi-domain hosts or CDNs, always pass -servername so OpenSSL sends the SNI extension.
1
2
3
4
5
6
7
8
# 1. Verify TLS 1.3 negotiation and inspect the full certificate chain
openssl s_client -connect api.example.com:443 \
-servername api.example.com -tls1_3 -showcerts < /dev/null
# 2. Quickly inspect subject, issuer, expiry dates, and SAN entries
openssl s_client -connect api.example.com:443 \
-servername api.example.com < /dev/null 2>/dev/null \
| openssl x509 -noout -subject -issuer -dates -ext subjectAltName
In the output, I check three things first:
- Under
Certificate chain, both depth0(Leaf) and depth1(Intermediate CA) are present. - The negotiated protocol reads
Protocol : TLSv1.3with an AEAD cipher. - The final verification line reports
Verify return code: 0 (ok).
Production certificate pitfalls and checklist
Most HTTPS outages I’ve debugged had nothing to do with cipher strength—they came from incomplete certificate chains, mismatched trust stores, or silent renewal failures.
Watch out for missing intermediate certificates: If you configure a web server with only the leaf certificate (
cert.pem) instead offullchain.pem, desktop browsers often mask the mistake by downloading the missing intermediate via the AIA (Authority Information Access) extension. Meanwhile,curl, JavaHttpClient, Go services, and mobile apps immediately fail withunable to verify the first certificateorPKIX path building failed.
- Java
cacertsvs. OS trust stores: Registering an internal Root CA in/etc/ssl/certsmakescurlpass, but the JVM ignores the OS store by default and only reads$JAVA_HOME/lib/security/cacerts, throwingSunCertPathBuilderException. Never disable validation with aTrustAllCertshack—import the internal CA into a dedicated truststore withkeytooland pass it via-Djavax.net.ssl.trustStore:
1
2
3
4
5
keytool -importcert -noprompt \
-alias internal-root-ca \
-file /etc/ssl/certs/internal-root-ca.crt \
-keystore /app/certs/custom-truststore.jks \
-storepass "${TRUSTSTORE_PASSWORD}"
- Expiry and reload drift: Short-lived certificates like Let’s Encrypt (90 days) rely on Certbot or
cert-managerfor renewal. Even when renewal succeeds on disk, Nginx or Envoy can keep serving the old expired certificate in memory if the reload hook fails. Always alert against the live HTTPS endpoint (for example, with Prometheus Blackbox Exporter at D-30, D-14, and D-7) rather than checking files on disk.
Pre-deploy TLS checklist
- Serve
fullchain.pem(leaf + intermediate) and confirmVerify return code: 0 (ok)withopenssl s_client -servername. - Enable TLS 1.3 and disable TLS 1.0/1.1 and static RSA suites at the ingress or reverse proxy.
- Keep 0-RTT early data disabled on non-idempotent API endpoints.
- Mount a custom JVM truststore when calling internal services signed by a private CA.
Monitor certificate expiration from outside the server via live HTTPS probes.
- RFC 8446 - The Transport Layer Security (TLS) Protocol Version 1.3
- RFC 5280 - Internet X.509 Public Key Infrastructure