How HTTPS and TLS Really Work: A Practical Guide

Security2026-11-23TryQuickToolBox

You've deployed your web app, configured HTTPS, and the browser shows a padlock. But when a user reports a certificate warning, or your API client fails with an SSL error, do you really know what's happening under the hood? Many developers treat TLS as a black box—until something breaks. This guide walks through how HTTPS and TLS actually work, from the handshake to certificate validation, and shows you how to diagnose common issues.

Why HTTPS Matters (Beyond the Padlock)

HTTPS is HTTP over TLS. It provides three guarantees: confidentiality (eavesdroppers can't read the data), integrity (data can't be modified in transit), and authentication (you're talking to the right server). Without TLS, passwords, session tokens, and personal data travel in plaintext. Modern browsers mark HTTP sites as "Not Secure," and many APIs (like geolocation and service workers) require HTTPS.

The TLS Handshake: Step by Step

Before any HTTP request is sent, the client and server perform a TLS handshake to agree on encryption keys. TLS 1.3 simplified this to one round trip. Here's what happens:

  1. Client Hello: The client sends supported TLS versions, cipher suites, and a random value (client random).
  2. Server Hello: The server picks a TLS version and cipher suite, sends its own random value (server random), and its certificate chain.
  3. Key Exchange: Using ephemeral Diffie-Hellman (in TLS 1.3), both sides derive a shared secret. The server's certificate proves its identity.
  4. Finished: Both sides verify the handshake integrity and switch to encrypted application data.

After the handshake, HTTP requests and responses are encrypted with symmetric keys (e.g., AES-GCM or ChaCha20-Poly1305). The certificate's role is only to authenticate the server during the handshake.

Certificate Validation: What the Browser Checks

When the client receives the server's certificate, it validates:

If any check fails, the browser shows a warning. For APIs, the client library throws an error like UNABLE_TO_VERIFY_LEAF_SIGNATURE.

Common HTTPS Problems and How to Debug Them

Here are typical issues and commands to diagnose them:

ProblemSymptomDebug Command
Expired certificateBrowser warning "Certificate has expired"openssl s_client -connect example.com:443 -servername example.com | openssl x509 -noout -dates
Hostname mismatch"Certificate is not valid for this domain"openssl s_client -connect example.com:443 -servername example.com | openssl x509 -noout -text | grep DNS
Incomplete chainSome clients fail, others workopenssl s_client -connect example.com:443 -showcerts
Protocol mismatch"SSL handshake failed"openssl s_client -connect example.com:443 -tls1_2

Use curl -vI https://example.com for a quick overview. For deeper inspection, openssl s_client shows the full handshake and certificate details.

Practical Example: Inspecting a Certificate with OpenSSL

Run this to see the certificate chain and expiration:

openssl s_client -connect example.com:443 -servername example.com -showcerts </dev/null

Look for Verify return code: 0 (ok) and the certificate's Not After date. If the chain is incomplete, you'll see errors like unable to get local issuer certificate.

Best Practices for HTTPS Configuration

FAQ

What is the difference between HTTPS and TLS?

HTTPS is HTTP layered on top of TLS. TLS is the cryptographic protocol that provides encryption and authentication; HTTPS is the application of TLS to HTTP traffic.

Why do some clients fail with SSL errors while browsers work?

Browsers often cache intermediate certificates or have more lenient chain-building. API clients may require a complete chain. Always serve the full certificate chain (server cert + intermediates).

How can I check if my certificate is expired?

Use openssl s_client -connect yourdomain.com:443 -servername yourdomain.com | openssl x509 -noout -dates to view the validity period. Alternatively, online tools like SSL Labs show expiration dates.

When you need to inspect or share certificate details, you can use the Timestamp Converter to translate certificate expiration dates into human-readable times.