ByteByte CityCity
All lessons
OSI Model

"Your Connection Is Not Private": TLS and Encoding | OSI Layer 6

8:11 Watch on YouTube

Monday morning and the company website is "down" — except it isn't. Every browser shows the same red page: "Your connection is not private." Ping works, door 443 is open, the handshake completes, the data arrives, and every browser refuses to unwrap it. Nothing about the road, the address, the door or the conversation is broken. What's broken is the packaging. In this episode Professor Flows explains the Presentation layer using Byte City's packing room: the label printer, the vacuum sealer and the shrink-wrap.

You'll learn

Chapters

  1. 0:00Monday morning: "Your connection is not private"
  2. 0:36The packing room: three machines
  3. 1:29The packing line: out, and back in
  4. 1:43The label printer: encoding
  5. 2:13What a wrong label looks like
  6. 3:00The vacuum sealer: compression
  7. 3:45Seal before you wrap
  8. 3:54The road is public
  9. 4:26The lock on door 443: TLS in three steps
  10. 5:12The real names, and the honest footnote
  11. 6:21The real thing: the expired certificate
  12. 7:03The mojibake email
  13. 7:22Exam corner
  14. 7:34Recap and next time

The written lesson

The problem: the website is down, except it isn't

A browser tab titled Privacy error, marked Not secure, at https://www.bytecity.tech. A red warning triangle above the words Your connection is not private and the code NET::ERR_CERT_DATE_INVALID, with Advanced and Back to safety buttons. A caption reads The data is arriving and every browser refuses to unwrap it
The road, the address, the door and the conversation all work. The browser still refuses.

Monday morning, and the company website is down. Except it isn't. Every browser, on every device, shows the same red page: "Your connection is not private."

Ping works, so the road and the address are fine. Door 443 is open. The handshake from the Layer 4 lesson completes. The data is arriving, and every browser refuses to unwrap it.

Nothing about the road, the address, the door or the conversation is broken. What is broken is the packaging. That is Layer 6 of the OSI model: the Presentation layer.

The packing room: three machines

A diagram titled The packing line, out and back in. On your computer, three boxes labelled Label, Seal and Wrap lead to The road, where a teal shrink-wrapped package with a padlock is leaving. At the far end, three boxes labelled Unwrap, Unseal and Read the label. A green banner reads On the way in: the same three things, backwards
Label, seal, wrap on the way out. Unwrap, unseal, read the label on the way in.

The Layer 5 lesson kept the conversation going. But before anything is handed to the truck, the data goes through the packing room off the garage. The packing room has three machines.

The label printer. Before you send anything, both ends have to agree what the contents are. Letters are written as numbers. A picture is written as a grid of colours. A film is written as frames. The label says which code was used, so the far end can read it. That is encoding.

The vacuum sealer. Anything that can be made smaller is made smaller, so it costs less to carry. That is compression.

The shrink-wrap. The road is public. So the data is wrapped in something nobody on the road can see through, and only the far end has the tool to take it off. That is encryption.

On the way out the order is label, seal, wrap. On the way in, the far end does the same three things backwards: unwrap, unseal, read the label. If any one of those steps fails, the data arrived, and nobody can use it.

All of this happens to the data itself, before the TCP tag is tied on and long before the mail bag and the crate.

The label printer: encoding

A diagram titled The label printer, encoding. The sender box shows don't with a label reading UTF-8. The receiver box shows don’t in red, with a tag reading Reads as: Windows-1252. Between them, the bytes on the road: 64 6F 6E E2 80 99 74, with the curly apostrophe highlighted as three bytes. A red banner reads Read with an older code table: don â € ™ t
Every byte arrived. The far end read them with the wrong code table.

A computer can't store the letter A. It stores a number, and both ends agree which number means A.

The oldest agreement you will meet is ASCII: 128 characters, enough for English and not much else. Today's agreement is UTF-8: every alphabet on Earth, every emoji, and it still reads plain ASCII exactly the same way.

Here is what a wrong label looks like. Someone types "don't" with a curly apostrophe and sends it as UTF-8. The letters d, o, n and t are one byte each. The curly apostrophe is three bytes: E2 80 99.

The far end reads those bytes with an older code table, Windows-1252, which gives every single byte its own character. E2 becomes â. 80 becomes €. 99 becomes ™. So the far end shows:

don’t

That garble has a name: mojibake. Nothing was lost on the road. Every byte arrived. The label was wrong, so the far end misread every one of them. If you ever see ’ where an apostrophe should be, you are looking at UTF-8 read as Windows-1252.

The same idea covers pictures, sound and film. JPEG, PNG, MP3 and MP4 are each an agreement about how to write something down, so the other side can read it back. Layer 6 doesn't deliver any of it. It makes sure both ends are speaking the same code.

The vacuum sealer: compression

A diagram titled The vacuum sealer, compression. Top row, Seal, then wrap: a 1,000 KB package goes through the sealer to 340 KB, then is wrapped, and stays 340 KB. Bottom row, Wrap, then seal: the 1,000 KB package is wrapped first and turns into a speckled square labelled looks like random noise, and after the sealer it is still 1,000 KB. A red banner reads Noise won't squeeze: once it's wrapped, the sealer can't find any air
Seal before you wrap: encrypted data looks like noise, and noise won't compress.

Most data is padded with air: repeated words, blocks of the same colour, silence. Compression squeezes the air out so the road carries less.

There are two kinds.

  • Lossless: zip files and PNG pictures. Unseal them and you get back exactly what went in, every bit.
  • Lossy: JPEG, MP3 and nearly all video. These throw away detail you can't see or hear, and it stays thrown away. A photo becomes a tenth of the size and looks the same. Re-save it twenty times and it doesn't.

In the Layer 4 lesson, video you can rewind rode the truck. This is the room that made it small enough to.

And there is one rule of the line: seal before you wrap. Once something is shrink-wrapped, it looks like random noise, and noise won't squeeze. Compress first, then encrypt. Do it the other way round and the sealer has nothing left to remove.

The shrink-wrap: encryption, and the lock on door 443

A diagram titled The lock on door 443, TLS. Your browser sends see-through packages along a plain lane to Door 80 Storefront, past an eye marking a copy at the switch-depot. A second lane marked TLS carries teal padlocked packages to Door 443 Storefront, with a large padlock above it and an address bar reading https://www.bytecity.tech. A green banner reads The padlock in your address bar: the whole conversation takes a fraction of a second
Door 80 is the storefront with no wrap. Door 443 is the same storefront with the lock: TLS.

Now the shrink-wrap, and the lock on door 443 that earlier lessons promised.

The road is public. In the Layer 2 lesson, the switch-depot sometimes copies a crate out of every ribbon. In the Layer 1 lesson, Wi-Fi is shouted into the air. Anyone on the road with a copy of plain data can read it.

So we wrap it. Encryption scrambles the contents with a key, and only someone holding the matching key can unscramble them. Everyone else sees noise.

Door 80 is the storefront with no wrap. Door 443 is the same storefront with the lock, and the lock's real name is TLS. Before the first page is sent, three things happen:

  1. The server shows its ID card. That card is a certificate, signed by an authority the browser already trusts.
  2. The browser and the server agree a key, in a way that someone watching every message still can't work out.
  3. From then on, everything is wrapped.

In modern TLS (version 1.3) the first two steps overlap: the key agreement starts in the very first hello messages, so the ID card itself travels already wrapped. The three jobs are the same. The whole conversation takes a fraction of a second, and it is what the padlock in your address bar means.

The ID card has an expiry date. If the card is out of date, the browser does exactly what it should: it refuses to trust the wrap. That is our Monday morning.

The real names, and the honest footnote

In Byte CityReal name
The packing roomThe Presentation layer
The label printerEncoding: character sets (ASCII, UTF-8) and data formats (JPEG, PNG, MP4)
The vacuum sealerCompression, lossless or lossy
The shrink-wrapEncryption
The lock on door 443TLS: a certificate, a key agreement, then a wrapped connection
The ID cardA certificate, issued by a certificate authority

For the exam, the names filed under Layer 6 are TLS and its ancestor SSL, the picture and video formats, and the character sets.

The honest footnote from the Layer 5 lesson applies here too. There is no packing-room box in the wiring. The label is written by your application. The sealing is done by a library. The wrapping is done by a library inside your browser. Layer 6 is a job description.

And one more honesty: engineers argue about which layer TLS really belongs to. We file it where the exam files it, at Layer 6, and move on.

The real thing: the ID card ran out

A Windows PowerShell window. Test-NetConnection www.bytecity.tech -Port 443 returns RemoteAddress 203.0.113.10 and TcpTestSucceeded: True. Below, openssl s_client -connect www.bytecity.tech:443 -servername www.bytecity.tech -brief prints CONNECTION ESTABLISHED, Protocol version TLSv1.3, Peer certificate CN = www.bytecity.tech, and Verification error: certificate has expired, highlighted. A caption reads Ask for the same card without a browser: door 443 answers, the card comes back
TcpTestSucceeded: True. Certificate has expired. The door is open; the packaging is refused.

Back to Monday morning. Click the padlock, or the warning where the padlock should be, and the browser shows you the ID card. Issued to our website, www.bytecity.tech. Issued by Byte City Root CA, an authority it trusts. Valid from 20 September last year, to 20 September this year. Today is Monday, the 21st: the card ran out yesterday.

Nobody on the road tampered with anything. The card simply ran out, and every browser did its job. The warning code says so: NET::ERR_CERT_DATE_INVALID.

You can ask for the same card from a terminal, without a browser.

  • Test-NetConnection www.bytecity.tech -Port 443 returns TcpTestSucceeded : True. Door 443 answers, so Layer 4 is fine.
  • openssl s_client -connect www.bytecity.tech:443 -servername www.bytecity.tech -brief opens the TLS conversation. The card comes back, and openssl reports: certificate has expired.
  • Pipe the card into openssl x509 -noout -dates and you see notAfter=Sep 20 23:59:59 2026 GMT. Yesterday. The full verify line reads Verify return code: 10 (certificate has expired).

Renew the certificate with the certificate authority, install it on the web server, and check again. The new card is valid to 19 December, and the verify code goes to zero: 0 (ok). Certificates run out on a schedule, and the fix is never on the road. It is in the packing room.

One more, because you will meet it. An email arrives full of strange characters where the apostrophes should be: "Please don’t restart the server until we’ve renewed the certificate". Open the message headers and look at its label, the character set: Content-Type: text/plain; charset=ISO-8859-1. The sender's label named one code, and the message was actually written in another, UTF-8. Nothing was lost; it was misread. Change the label to charset=UTF-8, and the words come back.

For the Network+ exam: encryption, compression and data-format conversion are functions of which OSI layer? Layer 6, Presentation. The shrink-wrap, the sealer and the label.

Quick answers

What does the presentation layer do?

Layer 6 makes sure the data can be read and trusted at the far end. It covers encoding (agreeing how characters and media are written as numbers), compression and encryption. In practice, those jobs are done by your applications and their libraries, not by a separate box.

What does "Your connection is not private" mean?

Your browser reached the server, but it would not trust the certificate the server presented. The most common cause is an expired certificate, shown as `NET::ERR_CERT_DATE_INVALID`. The fix is on the server: renew and install the certificate.

Is TLS at Layer 6?

The CompTIA Network+ exam files TLS and SSL under Layer 6, the Presentation layer, alongside encryption. Engineers argue about where TLS really belongs. For the exam, answer Layer 6.

Why do I see ’ instead of an apostrophe?

The text was written in UTF-8, where the curly apostrophe is three bytes, and read with an older code table like Windows-1252, which turns each byte into its own character. Nothing is missing. Read the text with the right character set, UTF-8, and it displays correctly.

What is the difference between lossless and lossy compression?

Lossless compression, such as zip and PNG, gives you back exactly what went in. Lossy compression, such as JPEG, MP3 and most video, throws away detail you are unlikely to notice, and that detail is gone for good.

Key terms

Presentation layer
—
Layer 6: encoding, compression and encryption, so the far end can read the data.
Encoding
—
the agreed code for writing characters and media as numbers, such as ASCII, UTF-8, JPEG or MP4.
Character set
—
the label that says which code a piece of text was written in.
Mojibake
—
garbled text caused by reading bytes with the wrong character set, such as don’t.
Compression
—
making data smaller to carry; lossless restores every bit, lossy discards detail for good.
Encryption
—
scrambling data with a key so only the holder of the matching key can read it.
TLS
—
the lock on door 443: a certificate, a key agreement, then a wrapped connection. SSL is its ancestor.
Certificate
—
the server's ID card, signed by a certificate authority the browser trusts, with an expiry date.
Next: Ping Works, Names Don't: DNS and the Application Layer | OSI Layer 7

Quick quiz

Five questions on this lesson. Pick an answer to see why.

  1. 1. Every browser shows "Your connection is not private" for the company site, yet Test-NetConnection to port 443 succeeds. What should be checked first?
  2. 2. An email shows "don’t" where "don't" should be. Every byte arrived intact. What is the most likely cause?
  3. 3. Why should data be compressed before it is encrypted, rather than after?
  4. 4. Which of these formats uses lossless compression, so every original bit comes back when it is opened?
  5. 5. A technician is explaining HTTPS to a trainee. Under which OSI layer does Network+ material file TLS, the encryption behind port 443?

Keep learning

Previous

Thumbnail for Why VoIP Calls Drop at 32 Seconds: The Session Layer | OSI Layer 58:17
OSI Model

Why VoIP Calls Drop at 32 Seconds: The Session Layer | OSI Layer 5

The delivery window, and the phone call that hangs up at thirty-two seconds.

8:17 Watch

Next

Thumbnail for Ping Works, Names Don't: DNS and the Application Layer | OSI Layer 78:07
OSI Model

Ping Works, Names Don't: DNS and the Application Layer | OSI Layer 7

The storefront, the mail room and the Yellow Pages, where every conversation begins.

8:07 Watch

Related

Thumbnail for The OSI Model Explained: 7 Layers in One City9:50
OSI Model

The OSI Model Explained: 7 Layers in One City

A city, seven floors, and why the model lost as a design and won as a language.

9:50 Watch

Related

Thumbnail for Ping Works, Page Won't Load: Ports, TCP and UDP | OSI Layer 49:32
OSI Model

Ping Works, Page Won't Load: Ports, TCP and UDP | OSI Layer 4

Numbered doors, the truck that calls ahead and the bullhorn that doesn't.

9:32 Watch

Exam objectives: CompTIA Network+ N10-009: 1.1 (OSI model, Layer 6), 1.4 (HTTPS 443, TLS), 4.1 (encryption in transit), 5.5 (troubleshooting a certificate error).

Byte City is not affiliated with or endorsed by CompTIA.