How HTTPS and TLS Really Work: Handshake, Certificates, and Best Practices

Security2026-11-13TryQuickToolBox

You type a URL, hit Enter, and the page loads securely. But what actually happens when you use HTTPS? Many developers treat TLS as a black box—until something breaks, like a certificate error or a performance issue. This article unpacks how HTTPS and TLS really work, from the handshake to certificate validation, with practical tips you can apply today.

What HTTPS and TLS Actually Are

HTTPS is HTTP over TLS (Transport Layer Security). TLS is a cryptographic protocol that provides three guarantees:

TLS evolved from SSL (Secure Sockets Layer). SSL is deprecated; modern systems use TLS 1.2 or 1.3. When you see “SSL certificate,” it's actually a TLS certificate.

The TLS Handshake in Plain English

Before any HTTP data flows, the client and server perform a handshake to agree on encryption parameters and verify identities. Here's a simplified version for TLS 1.3, the current standard:

  1. Client Hello: The client sends supported TLS versions, cipher suites, and a random value.
  2. Server Hello: The server picks a cipher suite, sends its own random value, and provides its certificate chain.
  3. Key Exchange: Both parties use ephemeral Diffie-Hellman to derive a shared secret without transmitting it.
  4. Finished: Both sides verify the handshake integrity and switch to encrypted communication.

TLS 1.3 reduces the handshake to one round trip, improving latency. TLS 1.2 requires two round trips and supports older cipher suites, some of which are insecure.

What About the Certificate?

The server's certificate contains its public key and identity information, signed by a Certificate Authority (CA). The client verifies:

If any check fails, the browser shows a warning. That's why an expired certificate breaks your site.

Encryption in Transit: Symmetric vs Asymmetric

TLS uses both types of encryption:

The handshake establishes a shared symmetric key that only the client and server know. Subsequent HTTP messages are encrypted with that key.

Practical TLS Configuration for Web Servers

Misconfiguration is common. Follow these guidelines to avoid weaknesses:

Here's a sample Nginx configuration snippet for modern TLS:

server {
    listen 443 ssl http2;
    server_name example.com;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305';
    ssl_prefer_server_ciphers off;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
}

Test your configuration with SSL Labs or similar tools to catch issues.

Common HTTPS Pitfalls and How to Avoid Them

PitfallConsequenceFix
Expired certificateBrowser warnings, lost trustAutomate renewal with monitoring
Mixed contentInsecure elements on HTTPS pageServe all resources over HTTPS
Weak ciphersVulnerable to attacksDisable legacy ciphers
Missing HSTSDowngrade attacks possibleAdd HSTS header

FAQ

What is the difference between HTTPS and TLS?

HTTPS is HTTP layered on top of TLS. TLS is the cryptographic protocol that secures the connection; HTTPS is the secure version of the HTTP protocol.

Do I need a certificate for local development?

Not strictly, but using a self-signed certificate or a tool like mkcert helps mimic production and avoid mixed-content issues. Browsers will warn about self-signed certs unless you trust them locally.

How often should certificates be renewed?

With Let's Encrypt, certificates are valid for 90 days and should be auto-renewed. Commercial certificates can last up to 398 days (as of current CA/Browser Forum rules), but shorter lifetimes are recommended.

Ready to inspect your server's TLS setup? Use our Nginx Log Analyzer to spot SSL errors and handshake failures in your logs.