Day 4 of 5
⏱ ~60 minutes
Cryptography in 5 Days — Day 4

TLS and Secure Protocols

TLS secures nearly all internet communication. Understanding how it works helps you configure it correctly, audit it effectively, and recognize when implementations are weak. Today covers TLS 1.3, cipher suites, and common TLS vulnerabilities.

The TLS 1.3 Handshake

TLS 1.3 simplified and hardened the handshake. Client sends: ClientHello with key share (Diffie-Hellman public value). Server responds: ServerHello with its key share + certificate + Finished MAC. Client verifies certificate, derives the same session key, and sends Finished. The entire handshake is just 1 round trip. TLS 1.3 removed weak cipher suites: no RC4, 3DES, MD5, SHA-1, or RSA key exchange. All TLS 1.3 cipher suites provide forward secrecy.

Forward Secrecy and Ephemeral Keys

Forward secrecy means compromising the server's long-term private key does not decrypt past traffic. TLS 1.3 mandates ECDHE (Elliptic Curve Diffie-Hellman Ephemeral) key exchange — a new key pair is generated for each session. Even if an attacker recorded all encrypted traffic for years, decrypting it later after getting the server's key is impossible.

Common TLS Vulnerabilities

BEAST (2011), POODLE (2014), DROWN, and HEARTBLEED were all caused by implementation flaws or downgrade attacks to old protocol versions. Configuration issues are more common today: allowing TLS 1.0/1.1, using weak cipher suites (RC4, 3DES), missing HSTS headers, accepting expired or self-signed certificates, and broken certificate chain validation in client apps.

bash
# Test TLS configuration with testssl.sh
testssl.sh https://precisionaiacademy.com

# Or use nmap for quick TLS audit
nmap -p 443 --script ssl-enum-ciphers precisionaiacademy.com

# OpenSSL: inspect a certificate
openssl s_client -connect precisionaiacademy.com:443 -servername precisionaiacademy.com

# Show certificate details
openssl s_client -connect precisionaiacademy.com:443 </dev/null 2>/dev/null \
  | openssl x509 -noout -dates -subject -issuer

# Check TLS version support
nmap -p 443 --script ssl-dh-params precisionaiacademy.com

# Python: verify TLS in code
import ssl, socket
ctx = ssl.create_default_context()
ctx.minimum_version = ssl.TLSVersion.TLSv1_2
with socket.create_connection(('precisionaiacademy.com', 443)) as sock:
    with ctx.wrap_socket(sock, server_hostname='precisionaiacademy.com') as ssock:
        print(ssock.version())
💡
Run testssl.sh against your production servers regularly. TLS configuration drifts over time as software updates change defaults. A quarterly TLS audit is standard security hygiene.
📝 Day 4 Exercise
Audit TLS Configuration
  1. Run testssl.sh against three websites you use regularly
  2. Identify any TLS 1.0/1.1 support (should be disabled)
  3. Check if HSTS (HTTP Strict Transport Security) is configured
  4. Use openssl s_client to inspect the full certificate chain
  5. Score each site using SSL Labs (ssllabs.com) and document the grades

Day 4 Summary

  • TLS 1.3 uses a 1-RTT handshake and mandates forward secrecy
  • Forward secrecy protects past sessions even if the private key is later compromised
  • ECDHE key exchange generates a fresh key pair for every TLS session
  • testssl.sh and SSL Labs audit TLS configuration comprehensively
  • Disable TLS 1.0/1.1; never allow RC4, 3DES, or export cipher suites
Challenge

Configure an Nginx server with an A+ SSL Labs score. Requirements: TLS 1.2/1.3 only, strong cipher suites, HSTS with 1-year max-age, OCSP stapling, and HTTP/2. Document every configuration directive and why it is needed.

Finished this lesson?