how/network
How does the browser "know" that example.com is real? A chain of signatures from the leaf cert through the intermediate up to the root, which is already built into the OS.
In the TLS handshake the server sends a certificate: a public key
plus a signature. But why should you trust that certificate at all? What
if an attacker just makes their own certificate with
CN=example.com?
The protection is a chain of signatures. The server's certificate is signed by an intermediate CA (Certificate Authority), that one is signed by a root CA, and the root is already built into the OS/browser during development. This chain of trust is what stops an attacker from forging anything without the private key of some CA.
On every HTTPS connection the browser runs 5 checks before it shows HTTPS. Press ▶ to see which ones.
In the Certificate message (part of the TLS handshake) the server sends its own leaf certificate + intermediates (if any). The browser gets this stack and must make sure that:
If even one check fails, you get a big red warning and a block by default.
recap
What to remember:
openssl s_client -connect example.com:443 shows the whole chain, or
openssl x509 -in cert.pem -text parses a single certificateRelated to [[tls-handshake|TLS handshake]] (the handshake that triggers this check). Without the cert chain an encrypted channel would still be possible, but server authentication would not.