Whose key is it?
In one sentence
Encryption and signatures only help with the right public key; a certificate is a signed statement, from an issuer you trust, binding a public key to a name.
The situation
You open your laptop in a café and log in to your bank over the café’s Wi-Fi. Someone else on that network could answer your browser before the bank does, with their own public key.
Your browser would then run a flawless key exchange and encrypt everything perfectly, with the wrong party. What stops this?
What is going on
The impostor in the middle
The attack in the situation is called a man-in-the-middle attack. The attacker runs one key exchange with you and another with the bank, and passes messages between them. Both connections are encrypted. The attacker reads everything.
Lessons 2 and 3 gave us encryption and signatures. Both depend on one thing: having the right public key. Encryption alone never tells you who is on the other end.
For a few people, you can compare fingerprints over a channel you already trust, for example by reading them out on a call. SSH asks you to do roughly this the first time you connect to a new server. It does not scale to the web.
A certificate binds a key to a name
A certificate is a signed statement: “this public key belongs to this name”. It is signed by an issuer, usually a certificate authority (CA), that your device already trusts, directly or through a chain (lesson 6). The format used on the web is X.509, profiled for the internet in RFC 5280.
The main fields:
- Subject and Subject Alternative Name (SAN): the names the certificate is for, such as
shop.example. - Public key: the subject’s public key.
- Issuer: who signed it.
- Validity: “not before” and “not after” dates.
- Serial number: unique for each certificate from that issuer.
- Extensions: what the certificate may be used for, and whether it may issue other certificates (lesson 5).
- Signature: the issuer’s signature over everything above.
Because the issuer signed it, changing any field breaks the signature. Your browser checks that signature with the issuer’s public key, checks that the name matches the site and that today is between the two dates, and only then accepts the public key inside.
What a certificate is not
A certificate is public. The server hands it to anyone who connects. It contains no private key, it is not encrypted, and it does not encrypt anything itself.
That is why copying it is useless to an impostor. During the connection the server must also prove it holds the private key that matches the public key in the certificate, by signing part of the handshake (lesson 7). The café attacker can copy the bank’s certificate but cannot make that signature.
Try it
Read this sample certificate field by field: the names, the issuer, the two validity dates, the serial number, the public key and the signature. Look for a private key: there is none.
Check
An attacker on café Wi-Fi copies your bank's real certificate and presents it to your browser. Why does the connection still fail?
RightNot quite The answer is A: The attacker cannot prove they hold the private key matching the public key in the certificate
- What happened
- The browser asks the server to sign part of the handshake with the matching private key. The attacker does not have it, so the check fails.
- Why
- A certificate is public by design; anyone can copy it. What proves identity is possession of the private key, which only the real bank holds.
- The rule
- A certificate alone proves nothing. The holder must prove possession of the matching private key.
Show answer
Answer A The attacker cannot prove they hold the private key matching the public key in the certificate
- What happened
- The browser asks the server to sign part of the handshake with the matching private key. The attacker does not have it, so the check fails.
- Why
- A certificate is public by design; anyone can copy it. What proves identity is possession of the private key, which only the real bank holds.
- The rule
- A certificate alone proves nothing. The holder must prove possession of the matching private key.
Which of these is inside a certificate?
RightNot quite The answer is B: The subject's names and public key, the issuer, validity dates, a serial number, extensions and the issuer's signature
- What happened
- A certificate holds a public key, names, the issuer, dates, a serial number, extensions and the issuer's signature.
- Why
- Its job is to bind a public key to a name, signed by someone you trust. Private keys never go in it, and traffic keys are agreed separately in the handshake.
- The rule
- A certificate is public: it binds a public key to a name and never contains a private key.
Show answer
Answer B The subject's names and public key, the issuer, validity dates, a serial number, extensions and the issuer's signature
- What happened
- A certificate holds a public key, names, the issuer, dates, a serial number, extensions and the issuer's signature.
- Why
- Its job is to bind a public key to a name, signed by someone you trust. Private keys never go in it, and traffic keys are agreed separately in the handshake.
- The rule
- A certificate is public: it binds a public key to a name and never contains a private key.
A laptop's clock is set two years in the future. What happens when it visits a normal HTTPS site?
RightNot quite The answer is C: The browser reports the site's certificate as expired
- What happened
- The browser compares the certificate's 'not after' date with its own clock and decides the certificate has expired.
- Why
- Validity checks use the device's local time. If that time is wrong, perfectly good certificates fail.
- The rule
- Certificate validity depends on the client's clock; when many sites fail at once on one device, check its date and time first.
Show answer
Answer C The browser reports the site's certificate as expired
- What happened
- The browser compares the certificate's 'not after' date with its own clock and decides the certificate has expired.
- Why
- Validity checks use the device's local time. If that time is wrong, perfectly good certificates fail.
- The rule
- Certificate validity depends on the client's clock; when many sites fail at once on one device, check its date and time first.
Takeaways
- Encryption without identity can be a private line to an impostor.
- A certificate is a signed statement, from an issuer your device trusts, that binds a public key to a name. It is public and holds no private key.
- The server proves it is the real owner by using the matching private key during the connection.
Go further
- Handbook: Whose key is it? Binding identity to keys
- Handbook: Anatomy of an X.509 certificate
- Next lesson: Names, jobs and asking for a certificate
Early edition. Checked against the standards; an independent expert review is in progress. Found a mistake? Tell us.