Lab 07: SSL/TLS Deep Dive

🎯 Objective

Use openssl s_client to connect to real HTTPS servers, inspect TLS certificates, understand the TLS handshake process, and identify weak vs strong cipher suites.

📚 Background

TLS (Transport Layer Security) is the protocol that makes HTTPS possible. It replaced the older SSL (Secure Sockets Layer) protocol, but many people still use the terms interchangeably. TLS provides three security guarantees: encryption (eavesdroppers can't read the data), authentication (you know who you're talking to), and integrity (data hasn't been tampered with).

The TLS handshake negotiates the cryptographic parameters before any application data flows. In TLS 1.3 (the current version), the handshake is faster (1 Round Trip Time vs 2 for TLS 1.2) and always provides forward secrecy. TLS 1.0 and 1.1 are deprecated — browsers no longer support them.

Cipher suites are combinations of algorithms for key exchange, authentication, bulk encryption, and MAC. A cipher suite like TLS_AES_256_GCM_SHA384 means: key exchange handled by TLS 1.3 mechanism, AES-256-GCM for bulk encryption, SHA-384 for integrity. Weak cipher suites (those using NULL, EXPORT, RC4, or DES) should be disabled.

Certificate pinning is an advanced technique where an application hardcodes the expected certificate or public key, refusing to connect if a different certificate is presented. This defeats compromised CA attacks but makes certificate rotation difficult.

⏱️ Estimated Time

40 minutes

📋 Prerequisites

  • Labs 4-6 (Cryptography) completed

  • Docker with innozverse-cybersec image

🛠️ Tools Used

  • openssl s_client — TLS connection testing

  • openssl x509 — Certificate parsing

  • openssl ciphers — Cipher suite listing

  • curl — HTTPS with TLS inspection

🔬 Lab Instructions

Step 1: Connect to a Server with openssl s_client

📸 Verified Output:

💡 What this means: TLSv1.3 is the protocol version — the latest and most secure. TLS_AES_256_GCM_SHA384 is the negotiated cipher suite (AES-256-GCM encryption, SHA-384 integrity). Verify return code: 0 (ok) means the certificate chain was valid — Google's cert is signed by a trusted CA.

Step 2: List Available Cipher Suites

📸 Verified Output:

💡 What this means: Each cipher suite specifies: Key exchange (Kx=ECDH means Elliptic Curve DH), Authentication (Au=RSA or ECDSA), Encryption (Enc=AESGCM(256)), and MAC/integrity (Mac=AEAD). HIGH filter removes weak ciphers. AEAD (Authenticated Encryption with Associated Data) ciphers like GCM are preferred as they combine encryption and integrity in one operation.

Step 3: Inspect a Certificate in Detail

📸 Verified Output:

💡 What this means: The certificate's Not Before and Not After define the validity period. The DNS: SAN entries list all valid hostnames. If a certificate is expired (Not After is in the past), browsers reject it. The Signature Algorithm: sha256WithRSAEncryption means DigiCert signed this cert with their RSA key using SHA-256. Never use SHA-1 signatures — they're cryptographically broken.

Step 4: Create a Self-Signed TLS Certificate

📸 Verified Output:

💡 What this means: In a self-signed certificate, Issuer and Subject are identical — the cert signed itself. For testing and internal services this is fine, but browsers will show "Your connection is not private" warnings. For production, use a CA-signed certificate (free ones from Let's Encrypt).

Step 5: Test TLS Version Support

📸 Verified Output:

💡 What this means: Google accepts both TLS 1.2 and 1.3. TLS 1.0 is rejected with "unsupported protocol" — Google correctly disabled old TLS versions. PCI-DSS compliance requires disabling TLS 1.0 and 1.1. If you find a server accepting TLS 1.0, that's a medium severity finding in a penetration test.

Step 6: Understand the TLS Handshake in Detail

📸 Verified Output:

💡 What this means: In TLS 1.3, the client speculatively sends its DH key share in the first message, so by the end of the first round trip, both sides have enough information to derive session keys. The certificate and encrypted data travel together in the second flight. TLS 1.3 also removed all legacy/weak cipher suites — you can't negotiate a weak cipher with TLS 1.3.

Step 7: Check HSTS (HTTP Strict Transport Security)

📸 Verified Output:

💡 What this means: HSTS prevents SSL stripping attacks — where a MITM attacker downgrades your HTTPS connection to HTTP before you notice. Once a browser sees HSTS, it refuses to connect via plain HTTP even if you type http://. The preload flag means the site is included in browser binary lists — protection even on first visit.

Step 8: Identify Certificate Transparency Logs

📸 Verified Output:

💡 What this means: Certificate Transparency was mandated by Chrome in 2018 — all publicly-trusted CAs must submit certificates to CT logs or Chrome rejects them. This was critical for detecting rogue certificates like those issued during the DigiNotar compromise (2011) and Symantec mis-issuances.

Step 9: TLS Configuration Best Practices

📸 Verified Output:

💡 What this means: SSL Labs scores A+ or A for well-configured servers. POODLE attacked SSL 3.0 (disable it). BEAST attacked TLS 1.0 (disable it). HEARTBLEED was an OpenSSL bug that leaked private key memory (patch and rotate keys immediately). The Qualys SSL Test is the industry standard for TLS configuration checking.

Step 10: Create and Start a Simple HTTPS Server

📸 Verified Output:

💡 What this means: We created a complete TLS server from scratch using Python's SSL module and an OpenSSL self-signed certificate. In production, you'd use nginx, Apache, or Caddy with Let's Encrypt certificates. Caddy is particularly nice because it handles TLS automatically.

✅ Verification

📸 Verified Output:

🚨 Common Mistakes

  • Using self-signed certs in production: Browsers block them, users get security warnings, some client libraries refuse to connect

  • Not checking certificate expiry: Expired certificates cause outages. Set up monitoring with tools like certbot renew --dry-run or certificate expiry alerts

  • Accepting weak cipher suites: Even if you support TLS 1.3, allowing TLS 1.0 with weak ciphers creates vulnerabilities

📝 Summary

  • TLS provides encryption, authentication, and integrity for network communications — the foundation of HTTPS

  • TLS 1.3 is the current standard: faster (1-RTT handshake), more secure (removed weak algorithms), mandatory forward secrecy

  • Cipher suite selection is critical — prefer ECDHE+AESGCM; disable NULL, RC4, DES, EXPORT ciphers

  • HSTS prevents SSL stripping attacks; Certificate Transparency logs help detect rogue certificate issuance

🔗 Further Reading

Last updated