Skip to main content

Day 20: How SSL/TLS Works 🔒

 Day 20: How SSL/TLS Works 🔒

Understanding how data is secured over the internet is non-negotiable for any tech professional. Today was a deep dive into SSL/TLS, the protocol that puts the "S" in HTTPS.

Key Takeaways:
1️⃣ HTTP vs. HTTPS: HTTP sends all data (even passwords!) in plain text, making it easy for hackers to "sniff." sniffing. HTTPS fixes this by using TLS (Transport Layer Security) to create an encrypted, secure channel between your browser and the server.
2️⃣ Hybrid Encryption: TLS cleverly uses both types of encryption. It starts with slower Asymmetric Encryption (a Public/Private key pair RSA) to only verify the server's identity (via a Certificate) and securely exchange a new, temporary Symmetric Key.
3️⃣ The Handshake: This initial process is the "TLS Handshake." Once complete, the rest of the session uses that super-fast Symmetric Key ⚡ to encrypt all the actual data (your logins, form data, etc.).
4️⃣ Simple Analogy: A server's Public Key is like an open padlock 🔓 it gives to everyone (inside its Certificate). You put your secret session key in a box, lock it with their padlock, and send it. Only the server has the matching Private Key 🔑 to open the box.
5️⃣ Why this matters: This is the foundation of internet trust. It prevents Man-in-the-Middle (MITM) attacks, protects user credentials 🛡️, and ensures data integrity. In DevOps, we are responsible for managing and automating these certificates for our services (e.g., in Kubernetes Ingress or Load Balancers) to keep our applications secure.



Day 20: How SSL/TLS Works 🔒

This document explains the "why" and "how" of SSL/TLS (Secure Sockets Layer / Transport Layer Security), the technology that powers HTTPS.

The Problem: The Insecure Internet (HTTP)

In a basic client-server model, you (the client) send requests (like GETPOSTPUT) to a server.

When you use plain HTTP (Hypertext Transfer Protocol), this communication is in plain text.

Let's say you try to log in to a website:

  1. Client ➡️ Server: POST /login (Username: "gaurav", Password: "pa$$w0rd123")
  2. Server ➡️ Client: HTTP 200 OK (Here's your data...)

hacker ðŸ•µ️ "sniffing" the network (e.g., on the same public Wi-Fi) can read this entire request. They now have your credentials. This is especially dangerous for banking, insurance, or any confidential site.


Attempt 1: Symmetric Encryption (A Good First Try)

What if we encrypt the data?

  • Idea: We can use a single symmetric key (a secret password) that both the client and server know.
  • Process:
    1. Client: Encrypts the login data with my_secret_key.
    2. Client ➡️ Server: "Here is the encrypted data."
    3. Client ➡️ Server: "P.S. The key to decrypt it is my_secret_key."
  • The Flaw: The hacker simply sniffs the network, intercepts the key, and then decrypts the data. We're back to square one.

Attempt 2: Asymmetric Encryption (Getting Warmer)

This method uses a key pair:

  1. Public Key 🔑 (Sharable): This key can only encrypt data. You can give it to anyone.
  2. Private Key 🤫 (Secret): This key can only decrypt data encrypted by its matching public key. You never share this.

Now, the server can generate a key pair.

  • Process:
    1. Server: Generates a public/private key pair (e.g., using openssl).
    2. Client: "Hi, I want to talk."
    3. Server ➡️ Client: "Great! Here is my Public Key ðŸ”‘."
    4. Client: "Awesome. I will generate a new Symmetric Key (let's call it the session_key)."
    5. Client: "I'll use your Public Key to encrypt my session_key."
    6. Client ➡️ Server: "Here is the encrypted session_key."
    7. Server: "Got it. I'll use my Private Key ðŸ¤« to decrypt it."
    8. Result: Both client and server now have the same secret session_key!

All future communication is encrypted using this fast symmetric session_key. The hacker can't intercept it, because even if they steal the encrypted package (in step 6), they don't have the server's private key to decrypt it.


The New Problem: The "Man-in-the-Middle" (MITM) Attack

What if the hacker is more clever?

  1. Client: "Hi Server, I want to connect."
  2. Hacker: (Intercepts the request) "Hi Server, I want to connect."
  3. Server ➡️ Hacker: "Hi! Here is my REAL Public Key ðŸ”‘."
  4. Hacker: (Saves the real key). "Hi Client! I'm the server. Here is my FAKE Public Key ðŸ”‘."
  5. Client: "Looks good! I'll encrypt my session_key with your FAKE Public Key."
  6. Client ➡️ Hacker: "Here is the encrypted session_key."
  7. Hacker: (Uses their FAKE Private Key ðŸ¤« to decrypt it). "Aha! I have the session_key!"
  8. Hacker: (Re-encrypts the session_key with the REAL Public Key).
  9. Hacker ➡️ Server: "Here is the encrypted session_key."

Result: The hacker is now an invisible proxy. They decrypt all your requests, read them, re-encrypt them, and send them to the server. You think you're secure, but you're not.


The Real Solution: SSL/TLS and Certificates 📜

How does the client know the Public Key it received actually belongs to the real server?

Answer: A Certificate Authority (CA) — a globally trusted third party (like DigiCertLet's Encrypt, etc.).

This introduces trust.

  1. Server: The server administrator (e.g., a DevOps engineer) generates a CSR (Certificate Signing Request). This file contains the server's domain name (google.com) and its Public Key.
  2. Server ➡️ CA: "Hi [DigiCert], please validate that I own google.com and sign my CSR."
  3. CA: The CA performs validation (e.g., checks DNS records, sends an email) to prove the server's identity.
  4. CA ➡️ Server: "All good! ✅ Here is your official, signed SSL Certificate."

This certificate is a public document that essentially says: "We, [DigiCert], swear that the public key inside this file belongs to [https://www.google.com/url?sa=E&source=gmail&q=google.com]."


The Final HTTPS Handshake (Putting It All Together)

Now, let's try that connection again, this time with HTTPS:

  1. Client (Browser): "Hi Server, I want to connect securely." (This is the Client Hello)
  2. Server: "Hi! Here is my SSL Certificate ðŸ“œ."
  3. Client (Browser): "Hmm... let me check this certificate."
    • "Is it for the correct domain (google.com)? Yes."
    • "Is it expired? No."
    • "Is it signed by a CA I trust (like DigiCert)? Yes! My browser has a built-in list of trusted CAs."
  4. Client (Browser): "I trust you! ✅ This public key is legit."
  5. Client: "I will now generate a random Symmetric Key (the session_key)."
  6. Client: "I'll encrypt this session_key using the server's trusted Public Key (from the certificate)."
  7. Client ➡️ Server: "Here is the encrypted session_key."
  8. Server: "Got it. I'll use my Private Key ðŸ¤« to decrypt it."
  9. Result: Both client and server securely established a shared session_key.
  10. Connection Secured: All further GET/POST requests are now encrypted with this symmetric key.

If a hacker tries the MITM attack again (Step 4 in that scenario), they can't provide a valid certificate for google.com signed by a trusted CA. The browser will immediately stop the connection and show a big red security warning ⚠️.

What about Intranet / Internal Sites?

For internal-only applications (e.g., a company dashboard), you don't need a public CA. The organization can create its own Custom CA. This custom CA certificate is then manually installed on all employee computers, telling their browsers to trust it. The process is the same, but the "root of trust" is the company itself, not a public entity.

Comments

Popular posts from this blog

Quick Guide to VCF Automation for VCD Administrators

  Quick Guide to VCF Automation for VCD Administrators VMware Cloud Foundation 9 (VCF 9) has been  released  and with it comes brand new Cloud Management Platform –  VCF Automation (VCFA)  which supercedes both Aria Automation and VMware Cloud Director (VCD). This blog post is intended for those people that know VCD quite well and want to understand how is VCFA similar or different to help them quickly orient in the new direction. It should be emphasized that VCFA is a new solution and not just rebranding of an old one. However it reuses a lot of components from its predecessors. The provider part of VCFA called Tenenat Manager is based on VCD code and the UI and APIs will be familiar to VCD admins, while the tenant part inherist a lot from Aria Automation and especially for VCD end-users will look brand new. Deployment and Architecture VCFA is generaly deployed from VCF Operations Fleet Management (former Aria Suite LCM embeded in VCF Ops. Fleet Management...
  Issue with Aria Automation Custom form Multi Value Picker and Data Grid https://knowledge.broadcom.com/external/article?articleNumber=345960 Products VMware Aria Suite Issue/Introduction Symptoms: Getting  error " Expected Type String but was Object ", w hen trying to use Complex Types in MultiValue Picker on the Aria for Automation Custom Form. Environment VMware vRealize Automation 8.x Cause This issue has been identified where the problem appears when a single column Multi Value Picker or Data Grid is used. Resolution This is a known issue. There is a workaround.  Workaround: As a workaround, try adding one empty column in the Multivalue picker without filling the options. So we can add one more column without filling the value which will be hidden(there is a button in the designer page that will hide the column). This way the end user will receive the same view.  
  "Cloud zone insights not available yet, please check after some time" message on Aria Automation https://knowledge.broadcom.com/external/article?articleNumber=314894 Products VMware Aria Suite Issue/Introduction Symptoms: The certificate for Aria operations has been replaced since it was initially added to Aria Automation as an integration. When accessing the Insights pane under  Cloud Assembly  ->  Infrastructure  ->  Cloud Zone  ->  Insights  the following message is displayed:   "Cloud zone insights not available yet, please check after some time." The  /var/log/services-logs/prelude/hcmp-service-app/file-logs/hcmp-service-app.log  file contains ssl errors similar to:   2022-08-25T20:06:43.989Z ERROR hcmp-service [host='hcmp-service-app-xxxxxxx-xxxx' thread='Thread-56' user='' org='<org_id>' trace='<trace_id>' parent='<parent_id>' span='<span_id>'] c.v.a.h.a.common.AlertEnu...