Skip to main content
CodingMarble

Technology explained

How Does HTTPS Work? The Padlock, Certificates and Handshake

HTTPS wraps your connection to a website in encryption and checks that the site really controls the domain you typed, so others on the network cannot read or alter the traffic. It does not tell you whether the site itself is honest, because a malicious site can also have a padlock.

By CodingMarble · Published · 4 min read

Two microwave dishes on a tower above a building
Photo: Miles Smith on Unsplash

What the padlock means, and what it does not

The padlock or similar icon near the address bar tells you one narrow thing: the connection between your browser and the site is encrypted, and the site proved it holds a valid certificate for that exact domain name. In other words, you are talking privately to whoever controls that domain. It says nothing about whether that owner is trustworthy.

That distinction is the most important thing to take from this guide. People often read the padlock as a seal of approval, and scammers rely on it. Getting a certificate for a domain is routine and inexpensive, so a fake shop or phishing page can show the same padlock as your bank. Always read the domain name itself, not only the icon. Browsers keep changing how they display security, so look at your own browser's help pages for what its current icons mean.

Encryption in transit

On plain HTTP, your data crosses many networks as readable text: the cafe's Wi-Fi, your internet provider, and every router along the way could read or change it. Anyone sharing your network could see which pages you opened and any form you submitted. Encryption in transit scrambles the data so that the people in the middle see only meaningless bytes, while the two ends can still read it. The underlying protocol is TLS, and HTTPS simply means HTTP running inside a TLS connection.

Two protections come together. Confidentiality means outsiders cannot read the traffic. Integrity means that if someone alters even a small part of it on the way, the change is detected and the connection fails. This is why a page delivered over HTTPS cannot be quietly modified to insert extra adverts or scripts by a network in the middle.

Certificates and certificate authorities

Encryption alone is not enough, because you must know who is on the other end. If you set up a private channel with an impostor, it is private but useless. That is the job of a certificate: a digital document that ties a domain name to a public key, signed by an organisation called a certificate authority, or CA.

Your device ships with a list of CAs it trusts. Before issuing a certificate, a CA checks that the requester controls the domain, commonly by asking them to place a specific value in a DNS record or on a web page at that domain. When your browser receives the certificate, it verifies the signature chain back to a trusted CA, confirms the name matches the address you typed, and checks that the certificate has not expired. If any check fails, you see a full-page warning. A certificate has a limited lifetime and must be renewed, and many sites renew automatically. Our guide on installing a free SSL certificate walks through that setup.

The handshake at a simple level

Before any page data moves, the browser and server perform a short negotiation called the handshake. Here is the idea without the mathematics, using a padlock analogy. The server has a public key that anyone may see, plus a matching private key that only it holds. Things locked with one can be proved with the other.

  1. Your browser says hello and lists the encryption methods and protocol versions it supports.
  2. The server picks a method and sends its certificate, which contains its public key.
  3. The browser verifies the certificate as described above.
  4. Using a key-agreement technique, both sides each compute the same fresh secret key without ever sending it across the network.
  5. From then on, both sides encrypt everything with that shared session key, which is fast and is discarded when the session ends.

The slow, clever public-key step is used only to agree on a secret and prove identity. The bulk of your traffic uses the faster shared key. Exact steps and speed differ between protocol versions, and details are best taken from current standards documents rather than memory.

What HTTPS does not protect

HTTPS protects the journey, not the destination. It does not stop a site from being fraudulent, from collecting the details you type into it, or from being hacked and serving malware over a perfectly valid connection. It does not hide that you visited a particular domain from your network, since the domain name is still visible in some of the setup traffic, though the specific pages and contents are not. It does not protect data after it arrives: whether a company stores your information safely is a separate question. And it cannot help if your own device is infected.

Practical tip: before entering a password or payment details, read the full domain in the address bar, watch for look-alike spellings, and prefer typing a known address or using a saved bookmark over following a link in a message.

How to check a certificate yourself, and why HTTP gets warnings

Click the icon beside the address in your browser and look for an option such as connection is secure, then certificate details. Wording differs by browser and version. You should see which domain names the certificate covers, who issued it, and the dates it is valid. If you work with servers, you can also read it from a terminal.

Shell· Print the issuer, subject and validity dates of a site's certificate
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -issuer -subject -dates

Browsers warn about plain HTTP because the risks are concrete: on an unencrypted page, anything you type, including passwords and form entries, travels readable, and anyone on the path can change what you see. Most browsers now label HTTP pages as not secure and may stop pages from using sensitive features. If you move a site to HTTPS and then see broken images or scripts, the cause is often old http links, covered in the guide on mixed content errors.

Need this built properly for your business?

CodingMarble is a remote studio in India that builds websites, apps and games on fixed packages with the scope written down before payment. Try the free tools we run, or start a project when you are ready.