The Scheme Picks the Port
Lesson 39 of 47 in Coddy's Networking with the Terminal course.
http:// and https:// differ in more than a letter. The scheme decides two things: which default port to use, 80 or 443, and whether to start a TLS handshake before sending anything.
That handshake is the first thing that happens, before any request line is written. Both sides agree on encryption and the server presents its certificate. Only then does the HTTP you know get sent, inside the encrypted channel.
So a port either speaks TLS or it does not. Ask for https:// from a plain HTTP port and there is no polite fallback: the handshake fails immediately, and curl reports exit code 35, an SSL connect error.
This is worth recognising, because it looks like the server is down when it is happily serving plain HTTP one scheme away.
Challenge
HardAsk a plain HTTP server for TLS and watch it refuse.
- Serve a folder on port 9129 in the usual way, which is plain HTTP
- Request
https://127.0.0.1:9129/and printtls=followed by curl's exit code
Expected output:
tls=3535 is curl's code for an SSL connect error.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Networking with the Terminal
Practice on your own: Terminal playground