How HTTPS and TLS Really Work: A Practical Guide

Security2026-11-27TryQuickToolBox

You've probably seen the padlock icon in your browser and assumed it means a site is secure. But what actually happens when you type https:// and hit enter? Understanding the TLS handshake and certificate validation helps you debug connection issues, avoid misconfigurations, and explain security to your team. This guide breaks down the real mechanics without the fluff.

The Problem: Why HTTPS Is More Than a Padlock

Many developers treat HTTPS as a checkbox: install a certificate, enable a redirect, done. But misconfigured TLS leads to expired certificates, weak cipher suites, and broken API clients. When a connection fails, you need to know where it failed—during the handshake, certificate verification, or data transfer. This article walks through the TLS 1.3 handshake step by step, explains what certificates actually prove, and shows how to inspect and debug HTTPS connections in practice.

What HTTPS Adds to HTTP

HTTPS is simply HTTP layered over TLS (Transport Layer Security). TLS provides three guarantees:

Without TLS, anyone on the network path—Wi-Fi operators, ISPs, or attackers—can read or modify traffic. With TLS, they can only see the domain you're connecting to (via SNI) and the timing of packets.

The TLS 1.3 Handshake in Plain English

TLS 1.3 simplified the handshake compared to older versions. Here's what happens in a typical browser-to-server connection:

  1. Client Hello: The browser sends a list of supported cipher suites, a key share (its ephemeral public key), and the server name (SNI).
  2. Server Hello: The server picks a cipher suite, sends its own key share, and includes its certificate chain.
  3. Key Derivation: Both sides compute the same shared secret using Diffie-Hellman. This secret never travels over the network.
  4. Finished: Both parties send a MAC over the handshake transcript to confirm nothing was tampered with.
  5. Application Data: HTTP requests and responses are encrypted with symmetric keys derived from the shared secret.

Notice that the certificate is sent in the clear during the handshake—it's public information. The client validates it before sending any sensitive data.

Why Forward Secrecy Matters

TLS 1.3 mandates ephemeral Diffie-Hellman (ECDHE), which provides forward secrecy. Even if the server's private key is later compromised, past sessions cannot be decrypted because the session keys were never stored. This is a key reason to prefer TLS 1.3 over TLS 1.2 with static RSA key exchange.

How Certificate Validation Works

A certificate binds a public key to a domain name and is signed by a Certificate Authority (CA). When your browser receives the certificate chain, it checks:

If any check fails, the browser shows a warning. For API clients like curl or Python's requests, the connection is aborted unless you explicitly disable verification (which you should never do in production).

Common TLS Misconfigurations and How to Spot Them

SymptomLikely CauseFix
Browser shows "certificate expired"Certificate not renewedAutomate renewal with Let's Encrypt or your CA.
API client fails with SSL errorMissing intermediate certificateInclude the full chain in your server config.
Mixed content warningsPage loads HTTP resourcesUpdate asset URLs to HTTPS or use relative URLs.
Handshake fails for old clientsTLS 1.0/1.1 disabledUpgrade clients or enable TLS 1.2 as a fallback.

Inspecting a TLS Connection in Practice

You can examine the handshake using command-line tools. For example, openssl s_client shows the certificate chain and negotiated cipher:

openssl s_client -connect example.com:443 -servername example.com -showcerts

Look for Verify return code: 0 (ok) and the protocol version (e.g., TLSv1.3). If the chain is incomplete, you'll see errors about unable to get local issuer certificate.

For a quick check of certificate expiration and SANs, use:

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -dates -subject -ext subjectAltName

In Node.js, you can log the TLS details of an HTTPS request:

const https = require('https');
https.get('https://example.com', (res) => {
  const socket = res.socket;
  console.log('Protocol:', socket.getProtocol());
  console.log('Cipher:', socket.getCipher());
  console.log('Certificate:', socket.getPeerCertificate().subject);
});

Configuring TLS on Your Server

For Nginx, a modern TLS configuration focuses on TLS 1.2 and 1.3, strong ciphers, and OCSP stapling. A minimal server block might look like:

server {
    listen 443 ssl http2;
    server_name example.com;
    ssl_certificate /etc/ssl/certs/example.com.fullchain.pem;
    ssl_certificate_key /etc/ssl/private/example.com.key;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256';
    ssl_prefer_server_ciphers off;
    ssl_stapling on;
    ssl_stapling_verify on;
    # ...
}

Always include the full chain (server certificate plus intermediates) in ssl_certificate. Missing intermediates are a common cause of mobile and API client failures.

Debugging HTTPS Issues: A Checklist

  1. Check certificate expiration with openssl x509 -enddate.
  2. Verify the chain using openssl verify -CAfile /etc/ssl/certs/ca-certificates.crt cert.pem.
  3. Test from multiple clients (browser, curl, mobile) to isolate client-specific trust store issues.
  4. Look for mixed content in browser dev tools; update all resource URLs to HTTPS.
  5. Ensure SNI is configured if you host multiple domains on one IP.

When analyzing server logs for TLS errors, tools like the Nginx Log Analyzer can help you spot handshake failures and slow TLS negotiations by parsing access logs.

FAQ

What's the difference between TLS and SSL?

SSL is the predecessor to TLS. Modern systems use TLS 1.2 or 1.3; SSL versions are deprecated and insecure. People often say "SSL certificate" out of habit, but the protocol is TLS.

Does HTTPS hide the domain I'm visiting?

No. The domain name is visible in the TLS handshake via SNI (unless Encrypted Client Hello is used, which is not yet universally deployed). HTTPS encrypts the content, not the destination hostname.

How often should I renew certificates?

Most CAs issue certificates valid for 90 days to 1 year. Automate renewal with tools like Let's Encrypt's certbot and set up monitoring to alert you before expiration.

Ready to debug your server's TLS performance? Use the Nginx Log Analyzer to parse access logs and identify handshake errors quickly.