Web Security Explained: HTTP, HTTPS, SSL & TLS

Web Security Explained: HTTP, HTTPS, SSL & TLS

When building a website, understanding HTTP, HTTPS, SSL, and TLS is essential for protecting user data and improving trust.

1. What is HTTP?

HTTP (HyperText Transfer Protocol) is the protocol used to transfer data between a web browser and a web server.

How HTTP Works

  1. User enters a website URL.
  2. Browser sends an HTTP request.
  3. Server processes the request.
  4. Server sends back a response.
  5. Browser displays the webpage.

Example

http://example.com

Problem with HTTP

HTTP sends data in plain text.

Anyone intercepting the connection can read:

  • Usernames
  • Passwords
  • Email addresses
  • Credit card information

2. What is HTTPS?

HTTPS (HyperText Transfer Protocol Secure) is the secure version of HTTP.

It uses SSL/TLS encryption to protect communication.

Example

https://example.com

Benefits

✅ Data Encryption

✅ Data Integrity

✅ Authentication

✅ Better SEO Rankings

✅ User Trust

3. What is SSL?

SSL (Secure Sockets Layer) is an older security technology used to encrypt communication.

SSL Versions

VersionStatus
SSL 1.0Never Released
SSL 2.0Deprecated
SSL 3.0Insecure

SSL is no longer considered secure.

Today, websites use TLS instead.

4. What is TLS?

TLS (Transport Layer Security) is the modern replacement for SSL.

It provides:

  • Strong encryption
  • Secure authentication
  • Data integrity verification

TLS Versions

VersionStatus
TLS 1.0Deprecated
TLS 1.1Deprecated
TLS 1.2Secure
TLS 1.3Recommended

5. HTTP vs HTTPS

FeatureHTTPHTTPS
Encryption❌ No✅ Yes
SecurityLowHigh
SEO RankingLowerBetter
TrustNot SecureSecure
Port80443

6. SSL vs TLS

FeatureSSLTLS
SecurityOlderModern
EncryptionWeakerStronger
PerformanceSlowerFaster
Usage TodayObsoleteStandard

7. How HTTPS Works (Step-by-Step)

Step 1: User Visits Website

https://mywebsite.com

Browser contacts the server.

Step 2: Server Sends SSL/TLS Certificate

The server provides a digital certificate containing:

  • Domain name
  • Public key
  • Certificate Authority information

Example:

mywebsite.com
Issued by Let's Encrypt

Step 3: Browser Verifies Certificate

The browser checks:

  • Is the certificate valid?
  • Is it expired?
  • Is it trusted?

If valid:

🔒 Secure Connection

Step 4: TLS Handshake

Browser and server agree on:

  • Encryption algorithm
  • Session keys
  • Security settings

Step 5: Secure Communication Begins

All data is encrypted:

Username: ********
Password: ********

Hackers cannot read the information.

8. What is a TLS Handshake?

The TLS Handshake establishes a secure connection.

Simplified Process

Browser
|
| ---- Hello ---->
|
Server
|
| <--- Certificate ---
|
Browser
|
| ---- Key Exchange --->
|
Secure Connection Established

After this:

Encrypted Data Transfer

9. How to Enable HTTPS on Your Website

Option 1: Using Let's Encrypt (Free)

Install Certbot.

For Ubuntu:

sudo apt update

sudo apt install certbot

For Nginx:

sudo apt install python3-certbot-nginx

Generate SSL certificate:

sudo certbot --nginx

Follow the prompts.

Option 2: Apache Server

Install Certbot:

sudo apt install python3-certbot-apache

Generate certificate:

sudo certbot --apache

10. Force HTTP to HTTPS

Nginx

server {
listen 80;
server_name mywebsite.com;

return 301 https://$host$request_uri;
}

Apache (.htaccess)

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

11. Check SSL/TLS Status

You can test your website using:

These tools check:

  • Certificate validity
  • TLS version support
  • Security configuration
  • Vulnerabilities

12. HTTPS for Laravel Applications

Update your .env:

APP_URL=https://yourdomain.com

Force HTTPS in AppServiceProvider.php:

use Illuminate\Support\Facades\URL;

public function boot()
{
URL::forceScheme('https');
}

Clear cache:

php artisan config:clear
php artisan cache:clear

Real-World Example

Without HTTPS:

Browser
|
| Username: admin
| Password: 123456
|
Internet

Anyone intercepting the traffic can read the data.

With HTTPS:

Browser
|
| Encrypted Data
|
Internet

Attackers only see unreadable encrypted information.

Summary

TermMeaning
HTTPStandard web communication protocol
HTTPSSecure version of HTTP
SSLOld encryption technology (deprecated)
TLSModern encryption technology
Port 80HTTP
Port 443HTTPS
RecommendedHTTPS + TLS 1.3

Best Practice: Always use HTTPS with TLS 1.2 or TLS 1.3, redirect all HTTP traffic to HTTPS, and use a trusted SSL/TLS certificate such as those provided by Let's Encrypt.

Souy Soeng

Souy Soeng

Hi there 👋, I’m Soeng Souy (StarCode Kh)
-------------------------------------------
🌱 I’m currently creating a sample Laravel and React Vue Livewire
👯 I’m looking to collaborate on open-source PHP & JavaScript projects
💬 Ask me about Laravel, MySQL, or Flutter
⚡ Fun fact: I love turning ☕️ into code!

Post a Comment

CAN FEEDBACK
close