SSL & mTLS: Ruby Rabbit and the Wolf in the Woods

updated 2026-10-06 · 11 min


ONELINE

A name is not proof — only a mark you already trust is. And once two animals know who they're talking to, they can create a secret together without hiding the conversation from anyone listening.

METAPHOR

Little Red Riding Hood, except Grandma starts asking for ID — with the actual protocol shown alongside each step of the story.

Cheat sheet: the forest map

Before entering the woods, here's how the animals map to the system:

StorySystem
RubyClient (ruby-checkout-service)
GrandmaServer / database (grandma-orders-db)
The Wise ElephantCertificate Authority (forest-ca)
The badgeA certificate — containing a public key
The secret sealThe private key that goes with it
The WolfAn untrusted, unauthenticated caller

One detail worth sitting with: Ruby's badge isn't secret. Anyone can look at it, even copy it. What Ruby has to keep secret is the seal that goes with it.

The two jobs of TLS

Everything in this story solves one of two problems:

  1. Authentication — who am I actually talking to?
  2. Confidentiality — can anyone listening read what we're saying?

Problem 1: "It's Ruby!"

Once upon a time, the animals of the forest trusted one another completely. When Ruby Rabbit visited her grandmother, she simply knocked and called:

"Grandma! It's Ruby!"

And Grandma opened the door. No badges, no passwords. Everyone knew everyone.

Until the Wolf arrived. He discovered that if he simply said he was Ruby, in a voice convincing enough, Grandma couldn't tell the difference. One afternoon he knocked, said the words, walked in, and left with Grandma's whole basket of berries.

When the real Ruby arrived, Grandma was shocked. "The Wolf came earlier — pretending to be you." Ruby asked how Grandma hadn't noticed.

"I didn't," Grandma said. "Saying a name was never proof of anything."

The Wise Elephant's badge, and the secret seal

The animals gathered beneath the oldest tree, worried. The Wise Elephant stood.

"Saying 'it's me' isn't enough anymore. I will give every animal a badge stamped with a mark only I make, and that everyone in this forest already knows by sight. From now on, ask to see it."

Ruby got a badge stamped RUBY RABBIT. Grandma got one stamped GRANDMA RABBIT. Notice this happened before anyone knocked on anyone's door — the badges were ready and waiting, long before they were ever needed.

But the Elephant knew a clever wolf might try to steal a badge, or copy one. So along with the badge, he gave each animal a secret seal.

"The badge is public. Anyone can look at it. But only you hold this seal. When someone checks your badge, you must also prove you hold the seal that goes with it."

The Wolf tried once more. He knocked. "Grandma! It's Ruby!"

"Show me your badge, and prove you have the seal," Grandma called back.

The Wolf had no badge from the Elephant — so he scratched something onto a leaf himself: RUBY RABBIT, in his own paw-writing, and held it up. Grandma looked closer.

"That's not the Elephant's mark. Anyone can write a name. Only the mark proves it."

The Wolf fled.

He wasn't finished being clever, though. A few days later, Ruby dropped her badge in the woods without noticing — the real one, with the real mark. The Wolf found it lying in the leaves and picked it up.

He went straight to the door. "Grandma! It's Ruby — look, here's my badge." He held it up. It was genuine.

Grandma looked closely. "That is my granddaughter's badge," she agreed. "But a badge is a thing — it can be dropped, found, copied. Only Ruby holds the seal that goes with it." She held out a scrap of bark. "Press your seal to this."

The Wolf had the badge. He did not have the seal. He pressed his paw against the bark, and nothing happened.

"A badge proves someone made this for you," Grandma said. "It doesn't prove you're the one holding it honestly."

The Wolf fled again — further than he'd gotten before, and still caught.

NAPKIN — Tech translation

Story: Grandma checks two separate things — whether the mark is genuinely the Elephant's, and whether the bearer can prove they hold the seal that goes with it. A forged mark fails the first check. A found or stolen badge fails the second.

TLS: The server validates the client's certificate — that it chains back to a trusted CA (forest-ca) — and then requires the client to use its private key to sign a challenge, proving it actually holds the key associated with that certificate, without ever revealing the key itself. The CA isn't present for this exchange; it signed the certificates once, in advance.

The distinction that matters: the certificate can be public. The private key must stay secret.

The database checks both the certificate and proof of the private key Three outcomes: a certificate signed by forest-ca with valid proof of the matching private key is accepted; a forged certificate with no valid signature is rejected; a genuine certificate presented without proof of the matching private key is also rejected. Real badge + seal — signed by forest-ca ✓ Forged leaf — no valid signature ✕ rejected Real badge, no seal — key proof fails ✕ rejected
A certificate alone is never enough — the database also checks proof of the private key that goes with it.

WATCHOUT

A badge with no mark you recognize isn't harmless — it's the leaf the Wolf scratched on. In real browsers, that's exactly what an untrusted or invalid certificate warning is: a badge nobody you already trust has vouched for. Clicking "continue anyway" is Grandma saying, "I don't recognise this mark, but I'll trust it anyway."

Problem 2: "How do we talk secretly?"

Grandma had a second problem. She'd never told anyone where the family's secret berry stash was — the sweetest in the forest — and now that Ruby was old enough to know, Grandma had to tell her, with the Wolf somewhere in the trees, listening.

So Grandma and Ruby decided they needed a secret way to talk — one they could create even while the Wolf was listening.

They played a strange little number game together. The Wolf listened to every word.

But when they finished, Grandma and Ruby had arrived at the same secret. The Wolf had heard everything.

He still didn't know the secret.

Grandma told Ruby where the family berry stash was. All the Wolf heard was:

"Flim-flam... moon... seven... blue."

The Wolf scratched his head. He could hear every word. He just couldn't understand what any of it meant.

NAPKIN — Tech translation

Story: Ruby and Grandma play a public number game to arrive at a shared secret.

TLS: That number game is a key-exchange algorithm such as ECDHE (Elliptic-Curve Diffie-Hellman Ephemeral). Both sides exchange mathematical information openly and independently derive the same shared secret, without ever sending the secret itself across the network — TLS then derives the keys that protect the rest of the conversation from it.

The surprising part: the key exchange itself doesn't have to be secret. The Wolf can hear the entire negotiation and still be unable to derive the secret.

Session key generated by key exchange ruby-checkout-service and grandma-orders-db derive the same session key via a key exchange such as ECDHE, safely, even though an eavesdropper hears the entire exchange. Session Key Generated (ECDHE) ruby-checkout-service grandma-orders-db both derive the same key — overheard in full, still unusable to the Wolf
The key exchange itself can happen in the open — that's the surprising part.

RECALL

The Wolf heard every single word of Grandma and Ruby's number game — none of it was whispered, none of it was hidden. He still couldn't work out the secret. What property would the real version of this negotiation need to have, for that to be possible?

ASIDE

Exactly how the number game let them land on the same secret, without ever meeting in private to agree on it first, is more surprising than this story lets on — that's the cleverest part of the whole mechanism, and worth its own lesson. For now: they played it, and the Wolf still came away empty-handed.

Problem 3: "How do I know YOU are Grandma?"

Ruby had been thinking about the badge checks.

"Grandma, you always check my badge. But how do I know some other animal didn't put on a cloak and copy your voice?"

Grandma realized she had only ever been the one doing the checking, never the one being checked. So the forest changed its rule once more: from then on, before any code got built or any word exchanged, both sides showed a badge first. Ruby checked Grandma's. Grandma checked Ruby's. Only then did they build their code and talk.

Ruby knew she was talking to Grandma. Grandma knew she was talking to Ruby. Neither had to simply take the other's word for it.

NAPKIN — Tech translation

Story: Ruby checks Grandma's badge, and Grandma checks Ruby's.

TLS: That's the "mutual" in mutual TLS (mTLS). In ordinary TLS, only the client verifies the server's identity. In mTLS, the server authenticates too.

TLS: "Prove you're Grandma."
mTLS: "Prove you're Grandma — and now you prove you're Ruby."

That second direction is what makes it mutual.

Client verifies server certificate ruby-checkout-service checks grandma-orders-db's certificate against forest-ca, completing the second direction of authentication that plain TLS leaves out. Client Verifies Server Certificate ruby-checkout-service grandma-orders-db signed by forest-ca — the same mark Ruby already trusted
Add this direction to the earlier one, and both sides have now checked each other. That's mTLS.

Putting the handshake together

Strip the forest away and this is an app-service (ruby-checkout-service) calling a database (grandma-orders-db) over mTLS. Lay the pieces from this story end to end, in the order they actually happen on the wire:

mTLS handshake between ruby-checkout-service and grandma-orders-db Ten-step TLS 1.3 mutual-authentication handshake: client hello with key share, server hello with key share, certificate request, server certificate, server certificate verify, server finished, client certificate, client certificate verify, client finished, then two-way encrypted application data. mTLS Handshake certificates issued by forest-ca ruby-checkout-service client grandma-orders-db server / database ClientHello + key share ServerHello + key share CertificateRequest ("show me yours") Server Certificate — Grandma's badge Server CertificateVerify — proof of her seal Finished (server) Client Certificate — Ruby's badge Client CertificateVerify — proof of her seal Finished (client) Encrypted Application Data SELECT * FROM orders
The full mTLS handshake between ruby-checkout-service and grandma-orders-db, in real wire order.

There's more beneath this simplified view, but the shape holds: the server proves itself, the client proves itself, both sides establish keying material, and only then does protected application data flow.

One more thing the story simplifies: in our telling, both Ruby and Grandma got their badges from the same Wise Elephant. In the real world, mTLS doesn't require both sides to share a CA — each side just needs to trust whichever chain authenticates the other.

FeatureTypical TLSMutual TLS (mTLS)
Server proves identityYesYes
Client proves identityUsually noYes
Encrypts trafficYesYes
Protects against eavesdroppingYesYes
Authenticates both endpointsNoYes

The Wolf tries anyway

Say the Wolf's pod tries to skip the app and call the database directly. He can send a ClientHello. Grandma can even respond. But when Grandma asks for a certificate —

"Who are you?"

— the Wolf has no certificate trusted by the forest. Or he presents one he made himself. Grandma checks the chain.

Unknown CA. Rejected.

The handshake ends before a single query runs.

mTLS handshake rejected between wolf-imposter and grandma-orders-db Four-step sequence ending in rejection: client hello, server hello, client presents a self-signed certificate, server rejects it as signed by an unknown certificate authority. mTLS Handshake — Rejected no certificate from forest-ca wolf-imposter client grandma-orders-db server / database Client Initiates Connection (ClientHello — TLS 1.3) Server Responds (ServerHello + Certificate) Client Presents Certificate (self-signed, not forest-ca) Server Verifies Client Certificate REJECTED — unknown CA ✕
The same handshake attempted by an unauthenticated caller — refused before a single query runs.

grandma-orders-db never had to know the Wolf by name to refuse him. It only had to know that nobody it already trusted had vouched for his certificate — the same reason the leaf, and later the stolen badge, never worked at the door.

One last distinction: authentication ≠ authorization

There's one more thing Grandma still has to decide. Knowing that Ruby really is Ruby doesn't automatically mean Ruby can do anything she wants.

mTLS answers one question:

"Who are you?"

It does not answer:

"What are you allowed to do?"

Ruby might be strongly authenticated and still not have permission to read every table, run every operation, or execute:

DROP TABLE orders;

That's a separate concern. mTLS answers who. Database permissions, RBAC, policy answer what.

The Wolf failed because he couldn't prove who he was. A legitimate Ruby might still be refused because she isn't allowed to perform a particular action. TLS secures the conversation. mTLS makes both sides prove who they are. Authorization decides what those identities are allowed to do.

Next lesson Python asyncio: Ruby Rabbit and the Bakery That Never Stood Still