Privacy note: We capture your IP address to provide customised and focused services. See our Privacy Policy.

Cybersecurity Essentials — Alpha School

Lesson 12: TLS and HTTPS: How the Padlock Really Works

Every time you see a padlock in your browser's address bar, a protocol called TLS, Transport Layer Security, is at work, and it is the most important piece of cryptography most people will ever use. TLS does three jobs at once: it encrypts the conversation between your browser and a website, it proves the website is who it claims to be, and it checks that nothing was altered on the way. It does all of this in a fraction of a second, every time you visit a secure site, using the symmetric and asymmetric cryptography from the last two lessons working together. This lesson walks through the TLS handshake, explains what the padlock does and does not promise, and shows you how to check a site's security for yourself.

The handshake, step by step

When your browser connects to a secure site, the two sides perform a handshake, a short negotiation that agrees on a shared secret in public. First, the browser says hello and lists the versions and ciphers it supports. Then the server replies with its certificate, which contains its public key and its identity, signed by a certificate authority, and the browser checks that certificate against the authorities it trusts. Then the two sides use asymmetric cryptography to agree on a symmetric key, often with a method called Diffie-Hellman key exchange, which lets them build a shared secret even though anyone watching can see every message, a trick based on maths that is easy to do and hard to undo. Finally, both sides switch to symmetric encryption with that key, and the conversation is private. Modern TLS, version 1.3, does all of this in a single round trip, so the padlock appears almost instantly.

Certificates and the chain of trust

A certificate is a document that says “this public key belongs to this website”, signed by a certificate authority, or CA, that your browser trusts. The browser checks three things: that the certificate was signed by a trusted CA, that it has not expired, and that it names the site you are visiting, because a valid certificate for one site does not prove anything about another. CAs themselves have certificates, signed by higher CAs, forming a chain of trust that ends at a root CA, whose certificate is built into your browser. Free CAs such as Let's Encrypt have made certificates available to every site, which is why HTTPS is now the default, and why a site without it is a warning sign. If a browser says a certificate is invalid, do not click through the warning: it means something is wrong, and the site may not be who it claims.

What the padlock does not promise

The padlock promises a private connection to the site named in the address bar, and it promises nothing else, which is a distinction worth understanding. It does not promise the site is honest: a phishing site can have a perfectly valid certificate and a padlock, because the certificate only proves the site controls the name, not that it is trustworthy. It does not hide which site you visited from your internet provider or your school, because the name is visible when the connection is set up. And it does not protect the site's own servers, so a hacked site can still serve malicious content over a secure connection. The padlock is therefore a necessary check, not a sufficient one: a site without it is unsafe, but a site with it still needs the checks from Lesson 8, such as verifying the sender and the address, before you trust it with your details.

Checking a site yourself

You can inspect any site's security in a few seconds. Click the padlock in the address bar and your browser will show the certificate, the issuing authority, and the expiry date, and most browsers will warn you if the certificate is expired or names a different site. You can also use the browser's developer tools, in the Security tab, to see the TLS version and the cipher in use: look for TLS 1.2 or 1.3, and be suspicious of older versions, which have known weaknesses. As a habit, glance at the address bar before entering a password or a card number: the address should start with https, the name should be the one you expect, and there should be no warning. That ten-second check, done every time, prevents the most common way people are tricked into giving their details to a fake site.

Watch & Learn

One video to watch for this unit, from a trusted educator.

Key Terms

TLS
Transport Layer Security, the protocol that encrypts web traffic and proves a site's identity.
HTTPS
HTTP over TLS; the secure version of the web, shown by a padlock in the browser.
Handshake
The short negotiation at the start of a TLS connection, in which the two sides agree on a shared secret.
Diffie-Hellman key exchange
A method for two sides to agree on a shared secret in public, even though anyone can see the messages.
Certificate
A document binding a public key to a website's identity, signed by a trusted certificate authority.
Chain of trust
The chain of signatures from a site's certificate up to a root certificate authority built into your browser.
Let's Encrypt
A free certificate authority that provides certificates to any site, making HTTPS the default.

Discussion Questions

  1. A phishing site has a padlock. Why does that not mean it is safe?
  2. Why is it safe for the TLS handshake to happen in public, where anyone can see the messages?
  3. Your browser warns that a site's certificate has expired. What should you do, and why?

Practice Questions

  1. What three jobs does TLS do?
  2. What does a certificate prove?
  3. What is the Diffie-Hellman key exchange for?
  4. Why does a padlock not mean a site is honest?
  5. What should you check in the address bar before entering a password?
Show answers
  1. It encrypts the conversation, proves the website's identity, and checks nothing was altered on the way. All three happen in the handshake and the encrypted session that follows.
  2. That a public key belongs to the website named in the certificate. It is signed by a certificate authority your browser trusts, and the browser checks the signature, the expiry and the name.
  3. It lets two sides agree on a shared secret in public. Even though anyone can see the messages, only the two sides can work out the secret.
  4. Because a certificate only proves the site controls its name, not that it is trustworthy. A phishing site can hold a valid certificate and a padlock.
  5. That the address starts with https, names the site you expect, and shows no warning. If anything is wrong, do not enter your details.
Keep reading to complete this lesson