Skip to main content

Lesson 7 of 10

SSL/TLS Deep Dive

TLS (Transport Layer Security) is the cryptographic protocol that secures HTTPS, email (SMTP/IMAPS), and virtually all encrypted internet traffic. Understanding TLS internals - the handshake, cipher suites, and common vulnerabilities - is essential for both offensive and defensive security.

50 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

TLS 1.3 Handshake

TLS 1.3 Handshake
# TLS 1.3 Handshake (simplified) - completes in 1 round trip

CLIENT → SERVER:
  ClientHello:
    - TLS version: 1.3
    - Supported cipher suites: [TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256]
    - Key share: ECDHE public key (ephemeral)
    - SNI: "api.example.com" (tells server which cert to present)

SERVER → CLIENT:
  ServerHello:
    - Selected cipher suite: TLS_AES_256_GCM_SHA384
    - Key share: ECDHE server public key (ephemeral)
    → Both sides now derive shared session key (ECDHE)
  Certificate: (server's X.509 certificate)
  CertificateVerify: (signature proving server owns private key)
  Finished: (HMAC over handshake transcript - integrity check)

CLIENT → SERVER:
  Finished: (HMAC proving client received everything correctly)
  → Encrypted application data begins immediately

Key properties:
  - Ephemeral ECDHE keys → Perfect Forward Secrecy
  - No RSA key exchange (removed in TLS 1.3)
  - 0-RTT resumption for repeat connections (with anti-replay protection)

Cipher Suite Components

  • Key Exchange: How the session key is established - ECDHE (ephemeral, provides PFS), RSA (no PFS - prohibited in TLS 1.3)
  • Authentication: How the server proves its identity - RSA, ECDSA, Ed25519
  • Bulk Encryption: How data is encrypted - AES-256-GCM (preferred), ChaCha20-Poly1305 (better on mobile), AES-128-GCM
  • MAC/AEAD: Ensures data integrity - GCM and Poly1305 are authenticated encryption modes (no separate MAC needed)
  • TLS 1.3 only allows AEAD cipher suites - eliminates the MAC-then-Encrypt vulnerabilities present in TLS 1.2

Critical TLS Vulnerabilities

  • BEAST (2011, TLS 1.0 CBC): Exploited predictable IV in CBC mode to decrypt client-to-server traffic. Fixed by upgrading to TLS 1.1+ or RC4 (RC4 is now also broken)
  • POODLE (2014, SSL 3.0 CBC): Padding oracle attack against SSL 3.0. Fix: disable SSL 3.0 entirely
  • Heartbleed (2014, OpenSSL): Buffer over-read in TLS heartbeat extension - leaked 64KB of server memory per request, exposing private keys, session tokens, credentials. Affected ~500,000 servers
  • FREAK (2015): Forced export-grade RSA keys (512-bit, breakable in hours). Fix: disable export cipher suites
  • DROWN (2016): SSLv2 oracle attack. Fix: disable SSLv2 on all servers (including email servers)
  • SSL Stripping (Moxie Marlinspike, 2009): MitM downgrades HTTPS to HTTP before the browser requests it. Defense: HSTS preloading

Hardening TLS Configuration (nginx)

Hardening TLS Configuration (nginx)
# /etc/nginx/snippets/ssl-params.conf - Production TLS hardening

# Only TLS 1.2 and 1.3 (disable 1.0, 1.1, SSL)
ssl_protocols TLSv1.2 TLSv1.3;

# Only strong cipher suites (TLS 1.2)
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;   # Let client choose (TLS 1.3 manages this)

# Perfect Forward Secrecy (Diffie-Hellman parameters)
ssl_dhparam /etc/nginx/dhparam.pem;   # Generate: openssl dhparam -out dhparam.pem 4096

# HSTS - force HTTPS for 1 year, include subdomains, preload
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

# OCSP Stapling - server fetches and caches OCSP response (faster, more private)
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;

# Session optimization
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_session_tickets off;     # Disable for better PFS

# Test your configuration: https://ssllabs.com/ssltest/ (aim for A+)

Common Mistakes

  • Allowing TLS 1.0 and 1.1 - both are deprecated by all major browsers; disable them
  • Not regularly testing TLS configuration - cipher suites and protocols that were secure become deprecated; test quarterly with SSL Labs
  • Forgetting HSTS - without HSTS, the first HTTP request after a certificate change is susceptible to SSL stripping

Tip

Tip

Practice SSLTLS Deep Dive in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).

Practice Task

Note

Practice Task - (1) Write a working example of SSLTLS Deep Dive from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with SSLTLS Deep Dive is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.

Key Takeaways

  • TLS (Transport Layer Security) is the cryptographic protocol that secures HTTPS, email (SMTP/IMAPS), and virtually all encrypted internet traffic.
  • Key Exchange: How the session key is established - ECDHE (ephemeral, provides PFS), RSA (no PFS - prohibited in TLS 1.3)
  • Authentication: How the server proves its identity - RSA, ECDSA, Ed25519
  • Bulk Encryption: How data is encrypted - AES-256-GCM (preferred), ChaCha20-Poly1305 (better on mobile), AES-128-GCM

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/10 done