🔒 Networking · Security
📅 Березень 2026⏱ 10 хв читання🟡 Середній

HTTPS & TLS 1.3: How Secure Connections Work

The padlock in your browser represents Transport Layer Security (TLS) — a protocol that authenticates the server, secretly negotiates a session key, and then encrypts every byte of data both ways. TLS 1.3 (2018) does all this in a single round-trip and is now used by over 90% of HTTPS sites.

1. What TLS Provides

TLS provides three security properties for a TCP connection:

HTTPS is simply HTTP running over TLS. The 's' in https:// means the TCP connection is wrapped in TLS before any HTTP data is sent.

2. X.509 Certificates

A TLS certificate is a digitally-signed document containing: the server's domain name, its public key, validity period, and the digital signature of a Certificate Authority (CA) certifying this information.

Your browser/OS ships with 100+ trusted root CAs (DigiCert, Let's Encrypt, Comodo, etc.). When a server presents its certificate, your browser follows the certificate chain: server cert → intermediate CA cert → root CA cert in your trust store. If the signature chain is valid and the domain matches, authentication succeeds.

Let's Encrypt issues free, automatically-renewed TLS certificates via the ACME protocol. Since its 2015 launch, it has issued billions of certificates, helping make HTTPS the default across the web. It uses Domain Validation (DV) — proves control of the domain but not the legal identity of the organisation.

3. TLS 1.3 Handshake

TLS 1.3 completes authentication and key exchange in a single round-trip (1-RTT). Resumption can be 0-RTT. The sequence:

→ Client
ClientHello
TLS version, random bytes, list of supported cipher suites, key_share (client's ECDHE public key for each supported group e.g. X25519)
← Server
ServerHello
Chosen cipher suite, key_share (server's ECDHE public key). Both sides can now derive session keys.
← Server
EncryptedExtensions
Additional extensions, all encrypted with the derived handshake key.
← Server
Certificate + CertificateVerify
Server's X.509 certificate chain and signature over the handshake transcript (proves possession of private key).
← Server
Finished
HMAC over entire handshake, verifying integrity.
→ Client
Finished
Client verifies everything and sends its Finished. Application data can now flow.

Total extra latency: 1 round-trip before application data. TLS 1.2 required 2 round-trips — TLS 1.3 is measurably faster for page loads.

4. ECDHE Key Exchange

ECDHE (Elliptic Curve Diffie-Hellman Ephemeral) allows two parties to derive a shared secret without transmitting it. Using elliptic curve X25519 (most common in TLS 1.3):

An eavesdropper sees A and B but cannot compute a × b × G without solving the elliptic curve discrete logarithm problem. The "Ephemeral" means new key pairs are generated for every TLS session, providing forward secrecy.

5. Record Layer & AEAD

After the handshake, all application data is encrypted using AEAD (Authenticated Encryption with Associated Data). TLS 1.3 mandates only two cipher suites:

AEAD provides both encryption and a MAC (authentication tag). The record structure: [header][encrypted payload + 16-byte authentication tag]. If even one byte of the ciphertext is modified, the tag verification fails and the connection is terminated. No separate HMAC required.

6. Forward Secrecy

TLS 1.3 mandates perfect forward secrecy (PFS): even if the server's private key is stolen later, recorded past traffic cannot be decrypted because ephemeral ECDHE keys are discarded after each session.

TLS 1.2 allowed non-ephemeral RSA key exchange, which had no forward secrecy — a nation-state adversary could record all encrypted traffic and decrypt it later when the server's private key is obtained. This vulnerability was used in mass surveillance programs.

7. HSTS & Common Pitfalls

HTTP Strict Transport Security (HSTS): A response header telling the browser to always use HTTPS for this domain for N seconds — prevents downgrade attacks. Major sites are in the HSTS Preload List shipped with browsers.

Common misconfiguration issues: