Why HTTPS
HTTPS (HTTP Secure) is HTTP with encryption. It protects data in transit between the browser and server.
Problems with HTTP
- Eavesdropping: Anyone on the network can read your data
- Tampering: Data can be modified in transit
- Impersonation: Attackers can pretend to be the server
- No integrity: You can't verify data hasn't been changed
What HTTPS Provides
| Protection | Description |
|---|---|
| Confidentiality | Data is encrypted, unreadable to third parties |
| Integrity | Data cannot be modified without detection |
| Authentication | Server identity is verified by certificates |
| Non-repudiation | Proof that data was sent/received |
Why HTTPS Matters
- User Trust: Browsers show 'Not Secure' for HTTP sites
- SEO: Google uses HTTPS as a ranking signal
- Data Protection: Encrypts passwords, credit cards, personal data
- API Security: Many APIs require HTTPS
- Compliance: Required for GDPR, PCI-DSS, HIPAA
- Performance: HTTP/2 requires HTTPS; TLS 1.3 is fast
HTTPS in Practice
HTTP (Insecure):
Browser ──────────────────────── Server
Plain text request/response
Anyone can read!
HTTPS (Secure):
Browser ═══════════════════════ Server
Encrypted tunnel
Only endpoints can read
TLS/SSL Handshake
The TLS (Transport Layer Security) handshake establishes a secure connection before data is exchanged.
TLS 1.3 Handshake (Modern)
Client Server
| |
| 1. ClientHello |
| (Supported TLS versions, |
| cipher suites, key share) |
|----------------------------------->|
| |
| 2. ServerHello |
| + Certificate |
| + Key Share |
| + Finished |
|<-----------------------------------|
| |
| 3. Client Finished |
| (Derives session keys) |
|----------------------------------->|
| |
| 4. Encrypted Data Exchange |
|<==================================>
Key Concepts
- Symmetric Encryption: Fast, same key for encrypt/decrypt (AES-256)
- Asymmetric Encryption: Slow, public/private key pair (RSA, ECC)
- Key Exchange: Agree on shared secret over public channel
- Certificate: Server's identity verified by trusted authority
TLS 1.3 vs TLS 1.2
| Feature | TLS 1.2 | TLS 1.3 |
|---|---|---|
| Handshake RTTs | 2 | 1 |
| Cipher Suites | Many (some weak) | Only secure ones |
| Forward Secrecy | Optional | Mandatory |
| 0-RTT | No | Yes (with trade-offs) |
Forward Secrecy
Even if the server's private key is compromised in the future, past communications remain secure because each session uses unique temporary keys.
Certificates
Digital certificates (SSL/TLS certificates) prove a server's identity and enable encryption.
Certificate Chain of Trust
Root CA (Pre-installed in browser)
└── Intermediate CA
└── Website Certificate
(www.example.com)
How Certificates Work
- Server sends its certificate to the browser
- Browser checks if the certificate is signed by a trusted CA
- Browser verifies the certificate hasn't expired
- Browser checks if the certificate matches the domain
- If all checks pass, secure connection is established
Types of Certificates
| Type | Validation Level | Cost | Use Case |
|---|---|---|---|
| Domain Validation (DV) | Domain ownership only | Free/Low | Personal sites |
| Organization Validation (OV) | Organization identity | Medium | Business sites |
| Extended Validation (EV) | Full identity verification | High | Banks, enterprises |
| Wildcard | Covers *.domain.com | Medium | Multiple subdomains |
| Multi-domain (SAN) | Multiple specific domains | High | Multiple sites |
Let's Encrypt
Free, automated certificate authority:
- Provides DV certificates
- Automatic renewal with certbot
- Trusted by all major browsers
- Used by 300M+ websites
Certificate Transparency
Public logs of all issued certificates help detect:
- Rogue certificates
- Mis-issuance
- CA compromises
Certificate Contents:
- Subject (domain name)
- Issuer (CA)
- Validity period
- Public key
- Signature
- Extensions (key usage, SAN)
Practice Problems
Create a reusable React component implementing HTTPS. Include proper state management and accessibility.
Solution
// Production-ready component with:
// - Proper TypeScript types
// - Accessibility (ARIA)
// - Error boundaries
// - Loading states
// - Memoization where neededWrite unit and integration tests for HTTPS using React Testing Library.
Solution
// Test coverage:
// 1. Rendering tests
// 2. Interaction tests
// 3. Edge case tests
// 4. Accessibility testsOptimize HTTPS for performance. Consider memoization, code splitting, and bundle size.
Solution
// Optimization techniques:
// 1. React.memo / useMemo / useCallback
// 2. Code splitting with lazy()
// 3. Virtual scrolling for lists
// 4. Image lazy loading
// 5. Bundle analysisQuiz
1. What does HTTPS stand for?
2. How many round trips does a TLS 1.3 handshake require?
3. What does Forward Secrecy protect against?
4. Which certificate type is free and automated?
Flashcards
Question
What are the three pillars of HTTPS?
Click to reveal answer
Answer
Confidentiality (encryption), Integrity (tamper-proof), Authentication (identity verification).
Question
What is the TLS handshake?
Click to reveal answer
Answer
The process where client and server agree on encryption methods, exchange keys, and establish a secure connection before data transfer.
Question
What is a Certificate Authority (CA)?
Click to reveal answer
Answer
A trusted organization that issues digital certificates to verify the identity of websites (e.g., Let's Encrypt, DigiCert).
Question
Why is HTTPS important for SEO?
Click to reveal answer
Answer
Google uses HTTPS as a ranking signal. HTTPS sites get a small boost in search rankings.
Question
What is HTTPS?
Click to reveal answer
Answer
HTTPS is a key concept in frontend development.
Revision Notes
Key Takeaways
- 1.HTTPS encrypts data, verifies identity, and ensures integrity
- 2.TLS 1.3 reduced handshake to 1 round trip
- 3.Digital certificates prove server identity via chain of trust
- 4.Let's Encrypt provides free DV certificates
- 5.HTTPS is essential for modern web security and SEO
Interview Tips
- •Explain the difference between symmetric and asymmetric encryption
- •Understand the TLS 1.3 handshake process
- •Know why certificate chain of trust matters
- •Be able to explain forward secrecy and its importance
Cheat Sheet
HTTPS Cheat Sheet
Why HTTPS:
- Encrypts data in transit
- Verifies server identity
- Required for HTTP/2
- SEO ranking signal
- Browser trust indicator
TLS 1.3 Handshake:
- ClientHello (key share)
- ServerHello + Cert + Key Share
- Client Finished
- Encrypted data exchange
Certificate Types:
- DV: Domain only (free)
- OV: Organization verified
- EV: Extended validation
- Wildcard: *.domain.com
Key Concepts:
- Symmetric encryption (AES) for data
- Asymmetric (RSA/ECC) for key exchange
- Forward secrecy protects past sessions