Skip to main content
Cryptography Basics
CHAPTER 09

SSL/TLS and HTTPS Basics

Updated: May 15, 2026
25 min read

# CHAPTER 9

SSL/TLS and HTTPS Basics

1. Introduction

Over the past 8 chapters, we have learned the individual puzzle pieces of cryptography: Symmetric encryption (fast but hard to share keys), Asymmetric encryption (easy to share keys but too slow), Hashing (integrity), and Digital Signatures (authentication). Now, we put the puzzle together. TLS (Transport Layer Security), formerly known as SSL, is the master protocol that combines all these techniques into a single, seamless workflow to create HTTPS, the secure foundation of the modern web. In this chapter, we will break down the intricate TLS Handshake.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Define the difference between HTTP and HTTPS.
  • Understand that TLS is the modern successor to SSL.
  • Explain the step-by-step process of the TLS Handshake.
  • Understand how Hybrid Cryptography solves the speed vs. security dilemma.
  • Recognize the role of Digital Certificates in browser security.

3. Beginner-Friendly Explanation

Imagine two spies meeting in a crowded restaurant.
  • The Problem (HTTP): If they just start talking, everyone in the restaurant can hear their secrets.
  • The Handshake (TLS):
  1. 1. Spy A says, "Let's speak in code. I know Russian and French." (Client Hello).
  1. 2. Spy B says, "I also know French. Let's use that." (Server Hello).
  1. 3. Spy B shows Spy A his government ID card to prove he is actually a spy. (The Certificate).
  1. 4. Spy A looks at the ID, verifies it is real, and then writes a secret "Decoder Ring" on a napkin.
  1. 5. Spy A puts the napkin in a tiny locked box (Encrypts it with Spy B's Public Key) and slides it across the table.
  1. 6. Spy B opens the box (Decrypts it with his Private Key) and gets the Decoder Ring.
  1. 7. The Secure Connection: Both spies now have the exact same Decoder Ring. For the rest of dinner, they talk at lightning speed using the Decoder Ring (Symmetric AES Encryption). No one in the restaurant can understand them.

4. HTTP vs. HTTPS

  • HTTP (Port 80): Hypertext Transfer Protocol. All data (including passwords and credit cards) is sent in plaintext. Anyone on your Wi-Fi network can read it.
  • HTTPS (Port 443): HTTP *Secure*. It is standard HTTP traffic, but it is wrapped inside an unbreakable TLS cryptographic tunnel before it leaves your computer.

*(Note: SSL - Secure Sockets Layer - is the old, deprecated 1990s version of this protocol. We technically use TLS 1.2 or TLS 1.3 today, though people still casually call it "SSL").*

5. The TLS Handshake (Hybrid Cryptography)

When you type https://bank.com, a complex conversation happens in milliseconds before the webpage loads:
  1. 1. Client Hello / Server Hello: Your browser and the bank agree on which encryption algorithms to use (the Cipher Suite).
  1. 2. Certificate Exchange: The bank sends your browser its Digital Certificate. This certificate contains the bank's Public Key and is digitally signed by a trusted authority to prove the bank is legitimate.
  1. 3. Key Exchange (Asymmetric): Your browser generates a brand new, random Symmetric Session Key (e.g., an AES key). Your browser encrypts this AES key using the bank's Public Key, and sends it to the bank.
  1. 4. Decryption: The bank receives the encrypted AES key and decrypts it using its Private Key (which never leaves the bank's server).
  1. 5. Secure Channel (Symmetric): Both your browser and the bank now possess the exact same AES Symmetric key. They switch to this fast AES key to encrypt the actual web page and your passwords.

*This is Hybrid Cryptography: We use slow Asymmetric math for 1 second just to safely share the fast Symmetric key.*

6. Perfect Forward Secrecy (PFS)

Modern TLS (1.3) uses an advanced feature called Perfect Forward Secrecy. Imagine a hacker records your encrypted HTTPS traffic for 5 years, hoping to one day steal the bank's Private Key. If the hacker finally steals the Private Key, can they decrypt the 5 years of recorded traffic? Without PFS: Yes. With PFS: No. PFS ensures that a brand new, temporary Symmetric key is generated for *every single session*, and then immediately destroyed when you close the browser. Even if the server's Private Key is compromised in the future, past conversations remain permanently encrypted.

7. Mini Project: Inspect an HTTPS Certificate

Let's verify the cryptography of a live website.

Step-by-Step Walkthrough:

  1. 1. Open your web browser and navigate to https://www.wikipedia.org.
  1. 2. Click the Padlock icon in the address bar next to the URL.
  1. 3. Click "Connection is secure" -> "Certificate is valid".
  1. 4. A window will open detailing the Digital Certificate. Look at the details:
  • Issued To: *.wikipedia.org
  • Issued By: GlobalSign or Let's Encrypt (The Certificate Authority).
  • Public Key Info: It will likely say RSA (2048 Bits) or ECC. This is the exact Public Key your browser uses to start the TLS handshake!

8. Real-World Scenarios

In the early 2010s, a tool called "Firesheep" was released. It allowed anyone sitting in a coffee shop to click one button and instantly steal the session cookies of anyone else on the Wi-Fi network who was using Facebook or Twitter. Why did this work? Because back then, Facebook only used HTTPS for the login page, but switched back to unencrypted HTTP for the rest of the browsing session. Firesheep forced the entire internet to adopt "HTTPS Everywhere," encrypting 100% of the session to protect users on public Wi-Fi.

9. Best Practices

  • HSTS (HTTP Strict Transport Security): Web administrators should enable the HSTS header. This tells the user's browser: "Never, ever connect to this site using insecure HTTP, even if the user types it in manually." This prevents hackers from intercepting the initial connection and stripping away the TLS encryption.
Many corporate environments install monitoring software that acts as an intentional "Man-in-the-Middle." The corporate firewall intercepts your HTTPS connection, decrypts it to scan for malware or data leaks, and then re-encrypts it before sending it to the internet. While legal on corporate-owned devices, employees should be aware that HTTPS does not guarantee privacy from their own IT department.

11. Exercises

  1. 1. Explain the "Hybrid" nature of the TLS handshake. Which part uses Asymmetric encryption, and which part uses Symmetric encryption?
  1. 2. What specific vulnerability does "Perfect Forward Secrecy" protect against?

12. FAQs

Q: Does a green padlock mean a website is completely safe? A: No! The padlock ONLY means the connection between your computer and the server is encrypted via TLS. It does not mean the server itself is honest. A hacker can easily set up a phishing site (fake-amazon.com) and get a free TLS certificate. The padlock guarantees privacy, not trust.

13. Interview Questions

  • Q: Walk me through the steps of a TLS 1.2 Handshake, detailing the exchange of cryptographic keys and certificates.
  • Q: Describe the functional difference between SSL and TLS. Why is SSL v3.0 considered deprecated in modern web architecture?

14. Summary

In Chapter 9, we orchestrated the various cryptographic primitives into the TLS protocol. We learned how HTTPS protects data in transit by executing a complex handshake: utilizing Asymmetric Public Keys to authenticate the server and securely exchange a fast, Symmetric Session Key. We explored how Perfect Forward Secrecy ensures past communications remain secure even if future keys are compromised. Ultimately, we established that TLS is the indispensable shield protecting global internet communication.

15. Next Chapter Recommendation

The TLS handshake relies entirely on your browser trusting the server's Digital Certificate. But who issues these certificates? How does your browser know which certificates to trust and which are fake? Proceed to Chapter 10: Public Key Infrastructure (PKI).

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·