Unit 7: Online data security · Secure Internet protocols

Article

Digital certificates and HTTPS

7 min read

A web address starts with https:// and your browser shows a small padlock. What does that padlock really promise? To answer, you first need to see a gap in public key encryption: it locks a message for a public key, but it does not tell you whose public key it is.

The gap: who owns this public key?

Suppose you visit shop.example. The site sends you a public key. But a criminal who sits between you and the shop could send you their own public key and pretend to be the shop. You would lock your card number for the criminal. Encryption worked perfectly, and you still lost.

You need someone you trust to confirm: "this public key really belongs to shop.example." That is the job of a certificate.

A digital certificate is a small file that says "this public key belongs to this website". It is issued by a certificate authority (CA), an organisation that checks who owns a site before it issues the certificate. The certificate is marked so that nobody can change it without being noticed.

Your browser comes with a built-in list of CAs it trusts. This is a trust model:

  1. You trust your browser.
  2. Your browser trusts the CAs on its list.
  3. A CA vouches for the website. So the browser trusts the website's public key.

Check your understanding

What is the role of a certificate authority (CA)?

HTTPS: HTTP with encryption

HTTPS is HTTP sent through an encrypted connection. The set-up and the encryption are done by a protocol called TLS (Transport Layer Security). The messages are the same as the HTTP you know (GET, 200 OK). They are just protected on the way. Here is the set-up, simplified:

Your browser sets up an HTTPS connection

  1. Earlier, the site's owner proved who they are to the CA.
  2. 1

    Certificate authority → Website

    A certificate for the site's public key

  3. 2

    Browser → Website

    Hello. I would like a secure connection.

  4. 3

    Website → Browser

    Here is my certificate and my public key.

  5. The browser checks three things. Is the name right? Was it issued by a CA I trust? Is it still valid?
  6. 4

    Browser → Website

    A fresh secret key, locked with the site's public key

  7. 5

    Website → Browser

    Ready. We both have the key.

  8. 6

    Browser → Website

    GET the page (encrypted)

  9. 7

    Website → Browser

    200 OK and the page (encrypted)

Public key encryption sets up the secret key. After that, the fast symmetric encryption does the rest of the work. Real TLS agrees the key in a slightly different way, but the idea is the same.

If a check fails, the browser shows a warning page instead. Common reasons: the certificate is out of date, it is for a different name, or it comes from a CA the browser does not know. Do not click through the warning.

On a rogue access point, an attacker can copy everything you send. With HTTPS, what they copy is ciphertext.

Check your understanding

A browser shows a padlock for a website. What does the padlock tell you?

What the padlock tells you, and what it does not

The padlock meansThe padlock does not mean
Your connection to the site is encryptedThe site is honest or safe
The public key belongs to the name in the address barThe site is not a scam or a phishing page
A CA you trust vouched for that nameYour device is free of malware
Your data is safe once it reaches the site

A criminal can get a certificate for my-bank-login.example, a name they own. The padlock is real, because the connection to that site is private. But it is not your bank. So read the address, not just the padlock.

Worked example

Leo types https://shop.example/pay and presses Enter.

  1. His browser asks the site to start a secure connection.
  2. The site sends its certificate. It names shop.example and was issued by a CA on the browser's list.
  3. The name matches the address and the dates are valid, so the browser trusts the public key.
  4. Browser and site set up a secret key, using the public key.
  5. The page and Leo's card number travel as ciphertext.

If the certificate had said shop-pay.example, step 3 would fail. The browser would warn Leo and not continue.

Common mistakes

  • "The padlock means the site is trustworthy." It means the connection is encrypted and the address is verified. Scam sites can have it too.
  • "The CA encrypts my messages." No. The CA only vouches for who owns a public key. It never sees your data.
  • "HTTPS is a different language from HTTP." It is the same HTTP, inside an encrypted TLS connection.
  • "Encryption alone is enough." Without a certificate, you cannot tell whether the key belongs to the real site.

On the exam

You may be asked: "What is the role of a certificate authority?" It issues digital certificates that confirm who owns a public key. Another common question is what HTTPS provides: an encrypted connection and a check of the site's identity, not a promise that the site is honest.

Key words

Digital certificate: a file that links a public key to its owner, such as a website.

Certificate authority (CA): a trusted organisation that checks owners and issues digital certificates.

HTTPS: HTTP sent over an encrypted connection.

TLS: the protocol that checks the certificate and encrypts the connection.

Trust model: browsers trust a list of CAs, and CAs vouch for websites.

AP® is a trademark registered by the College Board, which is not affiliated with, and does not endorse, this site. All lessons and questions here are written by JrCodex.