What crosses the network?
Choose HTTP or HTTPS, then walk through the login. Switch viewpoints to compare captured network bytes with what the browser and server can read.
TCP connection
SIMULATED CAPTUREThe HTTPS sequence assumes normal certificate validation succeeds or the known lab certificate exception has been accepted. Excerpts simplify HTTP headers, omit TCP acknowledgements and combine messages. Illustrative TLS bytes are not real ciphertext. The Python demo opens several TCP connections; a full capture has more packets.
A certificate identifies. Keys do different jobs.
The browser needs to protect the conversation and check who is at the other end. Click each item to see its role in a modern certificate-based TLS connection.
HNA training server
- Names / SAN
- 192.168.10.1, 127.0.0.1, localhost
- Issuer
- HNA server itself (self-signed)
- Validity
- Within its validity period
- Public key
- Public, shareable verification key
- Private key
- Never included in the certificate
A CA is a certificate authority: an issuer whose signature can be checked through the browser's trust system. A valid certificate binds names to a public key; it does not guarantee that a site's content or intentions are safe.
The browser also needs a valid certificate chain and acceptable algorithms. This model isolates the common checks. In TLS 1.3 the certificate travels inside the encrypted handshake after ServerHello; inspect it in the browser, not an undecrypted packet view.
How does TLS turn those pieces into encryption?
ClientHello and ServerHello negotiate parameters and exchange key shares. In a typical fresh TLS 1.3 connection, ephemeral Diffie-Hellman lets both sides derive shared secrets. The certificate and a private-key signature authenticate the server. Derived symmetric traffic keys then protect records with authenticated encryption, such as AES-GCM. The server's long-term private key and your login password are not the traffic keys.
Can someone decrypt the capture just by having lab-key.pem?
The certificate's private key alone does not decrypt TLS 1.3 or TLS 1.2 using ephemeral Diffie-Hellman. A session-key log from an endpoint can enable Wireshark decryption. That is a separate exercise: the observer now has extra secrets, not just a capture.
How does the server remember your login?
HTTP requests do not automatically remember previous logins. In our demo, a cookie carries a random session token. The server maps that token to an accepted login.
The server checks the username and password, then creates a random session token.
A Set-Cookie response tells the browser what to store and when it may send it.
The browser sends a Cookie request header. The server checks that the session is still valid.
HttpOnly limits JavaScript access; TLS protects it in transit. Cookie flags do not encrypt the token themselves.What do Path, lifetime and logout mean in our Python demo?
Path=/ covers paths across this host. With no Domain attribute, the cookie is host-only. Max-Age=1800 gives it a 30-minute browser lifetime; the server independently expires the session after 30 minutes. Sign out deletes the browser cookie and invalidates the server-side token. A server restart also clears sessions. Path is a routing rule, not a strong security boundary.
Do ports or localhost change the cookie rules?
Cookies are not isolated by TCP port. Our Python demo uses different cookie names for HTTP and HTTPS on the same host. Browsers may grant Secure-cookie exceptions to localhost and loopback addresses, with differences between browsers. This simulator deliberately uses a normal hostname to show the general HTTPS rule. Capture the actual loopback behavior separately rather than assuming every browser behaves identically.
Does SameSite stop every attack?
No. Strict blocks sending in cross-site contexts; Lax permits some top-level safe navigations such as a clicked GET link; None permits cross-site use and requires Secure. Other browser privacy rules may still block cookies. “Site” includes the scheme and is different from “origin”; changing a port alone does not make a different site. SameSite helps against some cross-site request forgery, but does not replace all CSRF defenses or prevent every XSS attack.
Take the model to Wireshark.
Use the existing Python package for a real login and capture. This lesson file can stay open beside it, even without an internet connection.
| Item | Your setup |
|---|---|
| Start on the server PC | py -3 server.py |
| HTTP login | http://127.0.0.1:8000/ |
| HTTPS login | https://127.0.0.1:8443/ |
| Capture adapter | Npcap: Adapter for loopback traffic capture |
| Wireshark display filter | tcp.port == 8000 || tcp.port == 8443 |
| Training account | cadet / Fleet2026 |
Everything runs on one PC. No switch or manual Ethernet addressing is required.
- Start capture before opening the HTTP page. Log in, stop capture and save it.
- Select
POST /login, then Follow → TCP Stream. Findusername=cadet&password=Fleet2026. Follow the later mission GET to findDOLPHIN-42. - Start a fresh capture and repeat over HTTPS. The included self-signed certificate causes an expected trust warning. Use only the specific lab exception permitted by your environment.
- Find ClientHello and ServerHello. TLS 1.3 is indicated in Supported Versions; legacy version fields may say TLS 1.2. Compare the encrypted records with the readable HTTP stream. You may also see a Change Cipher Spec record after ServerHello and NewSessionTicket messages after the handshake: TLS 1.3 sends a dummy Change Cipher Spec for compatibility with older network equipment, and session tickets allow later resumption. Both are expected. If port 8443 traffic appears only as TCP, use Decode As → TLS.
- For the initial comparison, leave Wireshark's TLS key-log setting empty and use no embedded decryption secrets. Sign out before repeating so the browser sends another login.
Predict: what can the observer still learn from HTTPS?
Endpoint IP addresses, TCP ports, traffic direction, packet lengths and timing remain visible. The credentials, HTTP path, cookies and briefing contents are encrypted in this demo. On other sites, unencrypted DNS or an unencrypted TLS server-name extension can reveal additional metadata. Our literal-IP demo needs no DNS lookup, and browsers do not send a server name for an IP address, so you will not find one in this ClientHello.
Predict: if the server can read the password, has HTTPS failed?
No. The server is an endpoint and must process the login. TLS protects the traffic between the endpoints. Browser developer tools also see decrypted HTTP locally; that does not mean the captured network traffic is plaintext.