---
title: How HTTPS Works: TLS Handshake, Certificates and Limits
url: https://www.masaischool.com/resources/how-https-works-explained
description: How HTTPS works: HTTP vs HTTPS, SSL vs TLS, the TLS 1.3 handshake, certificates and CAs, what HTTPS does not protect, and a Python certificate reader.
updated: 2026-12-01
publisher: Masai (https://www.masaischool.com)
---

# How HTTPS Works: TLS 1.3, Certificates, and What It Does Not Protect

> **Short answer**
>
> **HTTPS** is HTTP carried inside a TLS-encrypted connection. During the TLS handshake the browser and server agree on keys, and the server proves its identity with a certificate signed by a trusted certificate authority. After that, requests and responses are encrypted and tamper-evident. It does not hide which site you visit or make a site trustworthy.

This page is for learners moving from 'there is a padlock' to knowing what the padlock actually proves. It follows TLS 1.3 as specified in RFC 8446, adds the parts people get wrong, and includes a Python script that reads a real certificate from a public host. The script was run on 1 December 2026 with Python 3.9.6.

Read it after the [OSI model walk-through](https://www.masaischool.com/resources/osi-model-explained) and [TCP vs UDP](https://www.masaischool.com/resources/tcp-vs-udp-difference), since TLS sits between TCP and HTTP. For the security career side, see the [cybersecurity learning path](https://www.masaischool.com/resources/cybersecurity) and the [ethical hacking vs cybersecurity](https://www.masaischool.com/resources/cybersecurity/ethical-hacking-vs-cybersecurity) explainer.

## HTTP vs HTTPS, and what SSL/TLS is

HTTP sends requests and responses as readable text. Anyone on the path (shared Wi-Fi, a network operator) can read or alter them. **HTTPS is simply HTTP sent through a TLS connection**, normally on port 443. TLS (Transport Layer Security) provides three things: **confidentiality** (encryption), **integrity** (tampering is detected) and **authentication** of the server (you are talking to the owner of that host name).

SSL is the older name for the same idea. SSL 3.0 was prohibited by RFC 7568, and TLS 1.0 and 1.1 were formally deprecated by RFC 8996. Current software uses TLS 1.2 or 1.3; people still say 'SSL certificate' out of habit.

|  | HTTP | HTTPS |
|---|---|---|
| Default port | 80 | 443 |
| Encrypted in transit | No | Yes |
| Detects tampering | No | Yes |
| Proves server identity | No | Yes, via a certificate for the host name |
| Needs | Nothing | A certificate on the server |
| Browser treatment | Marked as not secure | Padlock; required by many browser features |

## The TLS 1.3 handshake, step by step

After the TCP handshake, TLS 1.3 needs one round trip before the client can send encrypted application data. The key idea is an **ephemeral Diffie-Hellman** key exchange: both sides contribute fresh values, derive the same secret, and never send it. The secret is not derived from the server's long-term key, so recording traffic today and stealing the server key later does not decrypt it. That property is called forward secrecy.

1. **ClientHello:** the client sends the TLS versions and cipher suites it supports, a random value, its key share for the key exchange, and extensions, including the server name (SNI) it wants.
2. **ServerHello:** the server picks a cipher suite and sends its own key share. From here both sides can compute the handshake keys, so everything that follows is encrypted.
3. **Encrypted server messages:** the server sends its certificate chain, a signature over the handshake made with the certificate's private key (CertificateVerify), and a Finished message that covers the whole handshake.
4. **Client Finished:** the client checks the certificate (see next section) and the signature, then sends its own Finished. Both sides derive traffic keys.
5. **Application data:** HTTP requests and responses flow, protected with an authenticated encryption algorithm such as AES-GCM or ChaCha20-Poly1305.

TLS 1.2 took two round trips and sent the certificate in plain text. TLS 1.3 removed older, weaker options and encrypts the certificate. It also allows **0-RTT early data** when resuming a previous session, but that data can be replayed by an attacker, so servers should accept it only for requests that are safe to repeat (RFC 8446, section 8).

## Certificates and certificate authorities

A certificate binds a public key to a host name. The server proves it holds the matching private key by signing the handshake. The browser trusts the binding only because a **certificate authority (CA)** signed it, and your browser or operating system ships a list of root CAs it trusts.

1. The server sends its **leaf certificate** and any **intermediate certificates**.
2. The browser follows signatures from the leaf, through the intermediates, to a root in its trust store.
3. It checks that the host name is listed in the certificate (the Subject Alternative Name field), that the dates are valid, and that the certificate has not been revoked.

Let's Encrypt, a free nonprofit CA, issues certificates valid for 90 days by default and offers an opt-in six-day short-lived option (its FAQ, read on 1 December 2026). Short lifetimes are why automatic renewal is standard. A domain-validated certificate only proves the requester controlled the domain, not that the owner is honest.

### Read a real certificate with Python

The script connects to a public host, lets Python verify the chain and host name, and prints the negotiated protocol, issuer and expiry. If there is no network or a proxy breaks TLS, it prints a message instead of crashing. Output below is from one successful run on 1 December 2026; issuers and expiry dates change when the site renews.import socket, ssl from datetime import datetime, timezone HOST = "www.python.org" try: ctx = ssl.create_default_context() # verifies the chain and the host name with socket.create_connection((HOST, 443), timeout=8) as raw: with ctx.wrap_socket(raw, server_hostname=HOST) as tls: cert = tls.getpeercert() issuer = dict(x[0] for x in cert["issuer"]) expiry = datetime.fromtimestamp(ssl.cert_time_to_seconds(cert["notAfter"]), timezone.utc) print("this Python build supports TLS 1.3:", ssl.HAS_TLSv1_3) print("host :", HOST) print("protocol :", tls.version()) print("cipher :", tls.cipher()[0]) print("issuer :", issuer.get("organizationName"), "/", issuer.get("commonName")) print("expires :", expiry.strftime("%d %b %Y"), "UTC") print("covers :", [v for k, v in cert["subjectAltName"]][:4]) except (OSError, ssl.SSLError) as e: print("Could not connect (no network, or a proxy intercepts TLS):", type(e).__name__)this Python build supports TLS 1.3: False host : www.python.org protocol : TLSv1.2 cipher : ECDHE-RSA-CHACHA20-POLY1305 issuer : GlobalSign nv-sa / GlobalSign Atlas R3 DV TLS CA 2025 Q4 expires : 14 Feb 2027 UTC covers : ['www.python.org', '*.python.org', 'python.org']

Two details in that output are worth explaining. The protocol line says TLSv1.2 and the first line says this Python build does not support TLS 1.3: the machine's Python is linked to an old LibreSSL, so it could not negotiate the newer protocol. Your own result may show TLSv1.3 on a newer Python and OpenSSL. This is a good reminder that TLS support depends on the library under your Python, not on Python itself. The issuer line is the intermediate CA that signed this site's certificate.

## What HTTPS protects and what it does not

| Question | With HTTPS? |
|---|---|
| Can someone on the Wi-Fi read the page, form fields or cookies? | No, they are encrypted |
| Can they change the page on the way (inject ads, scripts)? | No, tampering is detected |
| Can they see which IP address and usually which host name you visit? | Yes. The destination IP is visible, and the server name in ClientHello is normally readable unless Encrypted Client Hello is used |
| Can they see the exact URL path and query? | No, only the host is exposed, not the path |
| Can they see how much data moves and when? | Yes, sizes and timing remain visible |
| Are your DNS lookups hidden? | Not by HTTPS. They are separate unless DNS over HTTPS or similar is used |
| Is the site safe or honest? | No. Phishing sites can have valid certificates for their own domain |
| Is data safe on the server? | No. HTTPS ends at the server; stored data needs its own protection |
| Does it stop a bug such as SQL injection or XSS? | No. Those arrive inside the encrypted channel |

### Common misconceptions

- 'The padlock means the site is legitimate.' It means the connection is encrypted to whoever owns that domain. Check the domain name itself.
- 'HTTPS makes me anonymous.' The site, your network and your DNS provider still learn that you connected.
- 'SSL and TLS are different products.' TLS is the successor of SSL; the certificate files are the same kind.
- 'HTTPS is slow.' TLS 1.3 adds one round trip, and modern CPUs handle the encryption easily; session resumption and HTTP/2 or HTTP/3 reduce the cost further.
- 'My site does not take payments, so it does not need HTTPS.' Browsers restrict features on plain HTTP, and any login or form leaks without it.

A server can also tell browsers to use only HTTPS for a period with the HSTS header (RFC 6797), which stops a downgrade to plain HTTP on later visits. If you are deploying your own API, [deploy a Python API for free](https://www.masaischool.com/resources/build/deploy-python-api-free) covers hosts that provide HTTPS certificates for you.

## Frequently asked questions

### How does HTTPS work step by step?

The browser opens a TCP connection, then runs the TLS handshake: it sends supported ciphers and a key share, the server replies with its own key share and a certificate, the browser checks the certificate chain and host name, both derive session keys, and then encrypted HTTP requests and responses flow.

### What is the difference between HTTP and HTTPS?

HTTP sends data as readable text on port 80, so it can be read or changed in transit. HTTPS is HTTP inside TLS on port 443: it encrypts the traffic, detects tampering and lets the browser verify the server's certificate for the host name.

### What is the difference between SSL and TLS?

TLS is the newer, standardised successor to SSL. SSL 3.0 is prohibited and TLS 1.0 and 1.1 are deprecated, so current systems use TLS 1.2 or 1.3. 'SSL certificate' is still the common name for the X.509 certificate used by TLS.

### What happens in a TLS 1.3 handshake?

The client sends ClientHello with its key share, the server answers with ServerHello and its key share, and the rest of the handshake, including the certificate, is encrypted. After the Finished messages, both sides use derived keys for application data. It takes one round trip.

### Does HTTPS hide the websites I visit?

No. Your network can still see the destination IP address and usually the host name, since the server name travels in the ClientHello unless Encrypted Client Hello is used. HTTPS hides the page content, URL path and form data.

### Is a website with HTTPS always safe?

No. HTTPS only means the connection to that domain is encrypted and the domain owner got a certificate. Phishing and malicious sites can have valid certificates, and the site itself can still have vulnerabilities.
