In part 4 the request travelled as plain text, and anyone on the path could read it. HTTPS fixes that by adding TLS between TCP and HTTP. The browser then shows a padlock. We look at what the padlock says.
At the post office, the clerk at the front desk shows an ID card before Bub hands over a letter. Bub does not know the clerk, but the card carries the stamp of an inspector, and Bub keeps a short list of inspectors to trust. If the stamp is on that list, Bub accepts the name on the card. The card is the certificate, and an inspector is a certificate authority.
The server shows an ID card
The server’s ID card is a certificate. We can ask a server for its certificate and read the main fields:
docker run --rm alpine sh -c 'apk add -q openssl &&
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null |
openssl x509 -noout -subject -issuer -dates -ext subjectAltName' subject=CN=example.com issuer=C=US, O=SSL Corporation, CN=Cloudflare TLS Issuing ECC CA 3 notBefore=Sep 26 22:49:11 2026 GMT notAfter=Dec 25 22:56:35 2026 GMT X509v3 Subject Alternative Name: DNS:example.com, DNS:*.example.com
Here is what each marked part does:
- 1
openssl s_client -connect example.com:443opens a TLS connection and prints what the server shows. The option-servernamenames the site. - 2
</dev/nullcloses the input, so that the command ends. - 3
openssl x509 -noout -subject -issuer -dates -ext subjectAltNamereads the certificate and prints only these fields.
The certificate names the site it is for, example.com, and every name it covers, including *.example.com. It names who signed it, the issuer, and it has a start and an end date. This one is valid for 90 days. After the end date the certificate must be renewed, and a client rejects an expired one.
A chain of signatures
Your machine may not know the issuer in that output. It follows the signatures upwards until it reaches a root it has on its list. Ask for the whole chain:
docker run --rm alpine sh -c 'apk add -q openssl &&
openssl s_client -connect example.com:443 -servername example.com -showcerts </dev/null 2>/dev/null |
grep -E "^ [0-9] s:|^ i:"' 0 s:CN=example.com i:C=US, O=SSL Corporation, CN=Cloudflare TLS Issuing ECC CA 3 1 s:C=US, O=SSL Corporation, CN=Cloudflare TLS Issuing ECC CA 3 i:C=US, O=SSL Corporation, CN=SSL.com TLS Transit ECC CA R2 2 s:C=US, O=SSL Corporation, CN=SSL.com TLS Transit ECC CA R2 i:C=US, O=SSL Corporation, CN=SSL.com TLS ECC Root CA 2022 3 s:C=US, O=SSL Corporation, CN=SSL.com TLS ECC Root CA 2022 i:C=GB, ST=Greater Manchester, L=Salford, O=Comodo CA Limited, CN=AAA Certificate Services
Here is what each marked part does:
- 1
-showcertsprints every certificate in the chain. - 2
grep -E "^ [0-9] s:|^ i:"keeps the lines for the owner (s:) and the signer (i:) of each certificate.
Each s: is the owner of a certificate, and each i: is who signed it. The signer of one entry is the owner of the next. The site’s certificate is signed by an issuing authority. That authority is signed by another, and so on up to a root that the machine already trusts. Each signer is a certificate authority. The machine’s own list decides where the chain ends, so your output can end one step earlier or later.
What happens in the handshake
After TCP opens, the two sides run the TLS handshake. curl -v prints each message of it:
docker run --rm alpine sh -c 'apk add -q curl &&
curl -sv https://example.com -o /dev/null 2>&1 | grep -E "handshake, (Client|Server|Cert|CERT|Finished)"' * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS handshake, Finished (20):
Here is what each marked part does:
- 1
curl -svprints the details of the connection, andgrep -E "handshake, (Client|Server|Cert|CERT|Finished)"keeps the lines of the handshake messages.
The client says hello, names the site it wants and sends material for a key. The server answers with its own material, and both sides compute the same key. The messages after the hellos are encrypted, including the certificate. The server proves that it holds the secret key that belongs to the certificate (CERT verify). The Finished messages confirm that nobody changed the messages before them.
Client hello: the client names the site it wants to reach.
Three checks, three ways to fail
The client makes at least three checks on the certificate: the name matches, the dates are valid, and the chain ends at a trusted root. Each failed check gives a different error. Three test sites, each made to fail in one way, show them:
Which check does each site fail?
docker run --rm alpine sh -c 'apk add -q curl &&
for h in expired wrong.host self-signed; do
curl -sS -o /dev/null https://$h.badssl.com 2>&1 | head -1
done'curl: (60) SSL certificate OpenSSL verify result: certificate has expired (10) curl: (60) SSL: no alternative certificate subject name matches target hostname 'wrong.host.badssl.com' curl: (60) SSL certificate OpenSSL verify result: self-signed certificate (18)
Here is what each marked part does:
- 1The
forloop repeats the command for three test sites, made to fail in one way each. - 2
curl -sShides the progress meter but still shows errors.head -1keeps the first line.
The first certificate is past its end date. The second is valid but names another site, so the name check fails. The third is signed by its own owner, so the chain does not reach a trusted root. curl stops each time, and a browser shows a warning. Turning the checks off (curl -k) removes the error and also the protection.
What the padlock does not say
A passed check means three things. Nobody on the path can read the text. Nobody changed it without being detected. An authority that your machine trusts signed the certificate for this name. An authority usually checks only that the requester controls the name. A site with a name like your bank’s can have a valid certificate. The padlock says nothing about who runs a site or whether it is honest.
Key points
- TLS sits between TCP and HTTP. It encrypts the data and checks who is on the other end.
- The server shows a certificate: the names it covers, who signed it and for how long.
- The client follows the signatures up to a root on its own list. The name, the dates and the chain must all pass.
- The padlock proves privacy and a name that matches a trusted signature. It does not prove that the site is honest.
Next, in part 6: why the address your machine uses is borrowed, and what changes it on the way out.