1. Apa Itu SSL/TLS?
SSL (Secure Sockets Layer) dan TLS (Transport Layer Security) adalah protokol
kriptografi yang mengamankan komunikasi di jaringan. Ketika kamu melihat ikon gembok
🔒 di address bar browser dan URL dimulai dengan https://, itu artinya
koneksi antara browser kamu dan server dilindungi oleh SSL/TLS.
SSL adalah versi lama yang sekarang sudah usang (deprecated). TLS adalah penerusnya yang terus dikembangkan. Versi terbaru saat ini adalah TLS 1.3 (RFC 8446) yang dirilis pada tahun 2018. Meskipun orang masih menyebutnya "SSL", yang sebenarnya digunakan adalah TLS.
| Versi | Tahun | Status | Keterangan |
|---|---|---|---|
| SSL 2.0 | 1995 | ❌ Deprecated | Banyak celah keamanan fatal. Tidak boleh digunakan. |
| SSL 3.0 | 1996 | ❌ Deprecated | Rentan terhadap serangan POODLE. Tidak boleh digunakan. |
| TLS 1.0 | 1999 | ❌ Deprecated | Rentan BEAST. Semua browser utama sudah menolak. |
| TLS 1.1 | 2006 | ❌ Deprecated | Tidak mendukung cipher suite modern. Tidak boleh digunakan. |
| TLS 1.2 | 2008 | ✅ Aman | Masih banyak digunakan. Mendukung cipher suite kuat. |
| TLS 1.3 | 2018 | ✅ Terbaik | Handshake lebih cepat (1-RTT), keamanan lebih kuat, cipher suite minimal yang aman. |
Tanpa HTTPS, semua data yang dikirim antara browser dan server (termasuk password, nomor kartu kredit, dan data pribadi) dikirim dalam bentuk plain text yang bisa disadap oleh siapa saja di jaringan yang sama (public Wi-Fi, ISP, dll). Google juga menggunakan HTTPS sebagai faktor ranking SEO — situs tanpa HTTPS akan mendapat penalti di hasil pencarian.
2. Bagaimana TLS Bekerja: TLS Handshake
TLS handshake adalah proses negosiasi antara client (browser) dan server untuk menentukan parameter enkripsi yang akan digunakan. Proses ini terjadi dalam hitungan milidetik setiap kali kamu mengunjungi situs HTTPS.
Langkah Detail TLS 1.3 Handshake
Client Server
| |
| === 1. Client Hello === |
| • Supported TLS versions (1.3) |
| • Cipher suites yang didukung |
| • Key share (public key ECDHE/X25519) |
| • Random bytes (32 bytes) |
| • SNI (Server Name Indication) |
| -----------------------------------------------> |
| |
| === 2. Server Hello === |
| • TLS version yang dipilih (1.3) |
| • Cipher suite yang dipilih |
| • Key share (public key server) |
| • Random bytes (32 bytes) |
| <----------------------------------------------- |
| |
| === 3. Server Encrypted Extensions === |
| • Sertifikat X.509 (public key + identitas) |
| • Certificate Verify (tanda tangan digital) |
| • Finished (verification data) |
| <----------------------------------------------- |
| |
| === 4. Client Verification === |
| • Verifikasi sertifikat terhadap CA |
| • Derive session keys dari shared secret |
| • Finished (verification data) |
| -----------------------------------------------> |
| |
| === 5. Encrypted Communication === |
| • Data terenkripsi dengan AES-256-GCM |
| • Atau ChaCha20-Poly1305 |
| • Forward secrecy (Perfect Forward Secrecy) |
| <==============================================> |
TLS 1.2 membutuhkan 2 round-trip (2-RTT) untuk handshake, sedangkan TLS 1.3 hanya 1 round-trip (1-RTT) — bahkan mendukung 0-RTT untuk koneksi yang sudah pernah dilakukan sebelumnya. TLS 1.3 juga menghapus cipher suite lemah (RC4, 3DES, RSA key exchange) dan hanya mengizinkan cipher suite yang mendukung Perfect Forward Secrecy (PFS).
3. Jenis-Jenis Sertifikat SSL/TLS
Sertifikat SSL/TLS adalah file digital yang mengikat kunci publik ke identitas organisasi atau domain. Certificate Authority (CA) adalah pihak tepercaya yang menerbitkan dan menandatangani sertifikat ini.
| Jenis Sertifikat | Validasi | Biaya | Cocok Untuk |
|---|---|---|---|
| Domain Validation (DV) | Hanya verifikasi kepemilikan domain. Proses cepat (menit). | Gratis (Let's Encrypt) atau ~$10/tahun | Blog, situs personal, API, development |
| Organization Validation (OV) | Verifikasi domain + identitas organisasi. Proses 1-3 hari. | ~$50-200/tahun | Website bisnis, e-commerce kecil |
| Extended Validation (EV) | Verifikasi paling ketat: domain + organisasi + legal existence. Proses 1-2 minggu. | ~$150-500+/tahun | Bank, institusi keuangan, enterprise |
| Wildcard Certificate | Melindungi domain utama + semua subdomain (*.example.com). | Gratis (Let's Encrypt) atau ~$50-300/tahun | Website dengan banyak subdomain |
| Multi-Domain (SAN) | Satu sertifikat untuk beberapa domain berbeda. | ~$30-300/tahun | Multi-site, white-label services |
4. Setup Let's Encrypt dengan Certbot
Let's Encrypt adalah Certificate Authority (CA) gratis, otomatis, dan terbuka yang didirikan oleh Internet Security Research Group (ISRG). Dengan Let's Encrypt, siapa pun bisa mendapatkan sertifikat SSL/TLS yang valid tanpa biaya. Ini adalah cara paling populer untuk mengamankan website.
Install dan Konfigurasi Certbot
#!/bin/bash
# ============================================
# Let's Encrypt Setup dengan Certbot
# Untuk Nginx di Ubuntu/Debian
# ============================================
# ============================================
# 1. Install Certbot
# ============================================
# Metode snap (recommended)
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
# Atau dengan apt
sudo apt update
sudo apt install certbot python3-certbot-nginx -y
# ============================================
# 2. Dapatkan Sertifikat (Nginx plugin)
# ============================================
# Certbot akan otomatis konfigurasi Nginx
sudo certbot --nginx -d example.com -d www.example.com
# Atau tanpa plugin (hanya dapat sertifikat, konfigurasi manual)
sudo certbot certonly --webroot -w /var/www/html -d example.com -d www.example.com
# ============================================
# 3. Verifikasi Sertifikat
# ============================================
sudo certbot certificates
# Output:
# Certificate Name: example.com
# Domains: example.com www.example.com
# Expiry Date: 2026-09-23 (VALID: 89 days)
# Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
# Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem
# ============================================
# 4. Test Auto-Renewal
# ============================================
sudo certbot renew --dry-run
# Output: "Congratulations, all simulated renewals succeeded"
Konfigurasi Nginx dengan SSL
# ============================================
# Nginx SSL/TLS Configuration
# File: /etc/nginx/sites-available/example.com
# ============================================
# Redirect HTTP ke HTTPS
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
# HTTPS Server Block
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com www.example.com;
# ============================================
# Sertifikat SSL dari Let's Encrypt
# ============================================
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# ============================================
# TLS Protocol Configuration
# ============================================
# Hanya izinkan TLS 1.2 dan 1.3
ssl_protocols TLSv1.2 TLSv1.3;
# Cipher suite yang aman (urutkan berdasarkan keamanan)
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
# Gunakan server cipher preference (penting untuk keamanan)
ssl_prefer_server_ciphers on;
# ============================================
# SSL Session Configuration
# ============================================
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_session_tickets off; # Nonaktifkan untuk PFS sempurna
# ============================================
# DH Parameters (Diffie-Hellman)
# Generate: openssl dhparam -out /etc/nginx/dhparam.pem 2048
# ============================================
ssl_dhparam /etc/nginx/dhparam.pem;
# ============================================
# OCSP Stapling (performa + keamanan)
# ============================================
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
# ============================================
# Security Headers
# ============================================
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Root dan location blocks
root /var/www/example.com/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
Pastikan untuk generate Diffie-Hellman parameters sebelum mengaktifkan
ssl_dhparam:
openssl dhparam -out /etc/nginx/dhparam.pem 2048
Tanpa file ini, Nginx akan gagal restart. Proses generate bisa memakan waktu
5-15 menit tergantung spesifikasi server.
5. Certificate Renewal Otomatis
Sertifikat Let's Encrypt memiliki masa berlaku 90 hari. Certbot sudah mengatur auto-renewal secara otomatis saat install, tetapi penting untuk memverifikasi dan menguji proses renewal agar tidak terjadi insiden sertifikat kadaluarsa.
#!/bin/bash
# ============================================
# Let's Encrypt Auto-Renewal Setup & Testing
# ============================================
# ============================================
# 1. Cek timer systemd (sudah dibuat oleh certbot)
# ============================================
sudo systemctl status certbot.timer
# Harus menunjukkan "Active: active (waiting)"
# Lihat jadwal renewal
sudo systemctl list-timers | grep certbot
# ============================================
# 2. Test renewal tanpa benar-benar renew
# ============================================
sudo certbot renew --dry-run
# ============================================
# 3. Manual renewal (jika diperlukan)
# ============================================
sudo certbot renew
# ============================================
# 4. Post-renewal hook: Reload web server
# Certbot sudah membuat hook ini otomatis, tapi
# jika perlu manual:
# ============================================
cat > /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh << 'EOF'
#!/bin/bash
nginx -t && systemctl reload nginx
echo "$(date): Nginx reloaded after cert renewal" >> /var/log/certbot-renewal.log
EOF
chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
# ============================================
# 5. Monitoring expiry sertifikat
# ============================================
# Cek expiry dari command line
openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| openssl x509 -noout -dates
# Cek expiry dari jarak jauh
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| openssl x509 -noout -enddate
# Script monitoring sederhana
cat > /usr/local/bin/check-ssl-expiry.sh << 'SCRIPT'
#!/bin/bash
DOMAIN="$1"
EXPIRY=$(echo | openssl s_client -connect "$DOMAIN:443" -servername "$DOMAIN" 2>/dev/null \
| openssl x509 -noout -enddate | cut -d= -f2)
EXPIRY_EPOCH=$(date -d "$EXPIRY" +%s)
NOW_EPOCH=$(date +%s)
DAYS_LEFT=$(( (EXPIRY_EPOCH - NOW_EPOCH) / 86400 ))
if [ "$DAYS_LEFT" -lt 30 ]; then
echo "⚠️ WARNING: Sertifikat $DOMAIN kadaluarsa dalam $DAYS_LEFT hari!"
# Kirim notifikasi (opsional)
# curl -X POST "https://hooks.slack.com/..." -d "{\"text\":\"SSL $DOMAIN expires in $DAYS_LEFT days\"}"
fi
SCRIPT
chmod +x /usr/local/bin/check-ssl-expiry.sh
# Jalankan pengecekan
/usr/local/bin/check-ssl-expiry.sh example.com
6. Konfigurasi TLS yang Aman
Konfigurasi TLS yang tepat sangat penting untuk memastikan komunikasi benar-benar aman. Kesalahan konfigurasi dapat membuat enkripsi menjadi lemah atau bahkan tidak efektif sama sekali.
Apache SSL Configuration
# ============================================
# Apache SSL Configuration
# File: /etc/apache2/sites-available/example-ssl.conf
# ============================================
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/html
# ============================================
# Sertifikat SSL
# ============================================
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
# ============================================
# TLS Protocol & Cipher Configuration
# ============================================
SSLProtocol -all +TLSv1.2 +TLSv1.3
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384
SSLHonorCipherOrder on
SSLCompression off
SSLSessionTickets off
# ============================================
# OCSP Stapling
# ============================================
SSLUseStapling on
SSLStaplingResponderTimeout 5
SSLStaplingReturnResponderErrors off
# ============================================
# Security Headers
# ============================================
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
</VirtualHost>
# Redirect HTTP ke HTTPS
<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://example.com/
</VirtualHost>
Gunakan Mozilla SSL Configuration Generator untuk menghasilkan konfigurasi TLS yang optimal untuk Nginx, Apache, HAProxy, atau server lainnya. Pilih level keamanan: Modern (TLS 1.3 saja), Intermediate (TLS 1.2+), atau Old (kompatibel dengan perangkat lama).
7. HTTP Strict Transport Security (HSTS)
HSTS adalah mekanisme keamanan yang memberitahu browser bahwa situs hanya boleh diakses melalui HTTPS. Setelah HSTS diaktifkan, browser akan secara otomatis mengubah semua request HTTP ke HTTPS — bahkan sebelum request pertama dikirim. Ini mencegah serangan SSL stripping di mana penyerang menurunkan koneksi HTTPS ke HTTP.
# ============================================
# HSTS Header Configuration
# ============================================
# Langkah 1: Testing mode (max-age pendek — 5 menit)
# Gunakan ini dulu untuk memastikan tidak ada mixed content
add_header Strict-Transport-Security "max-age=300" always;
# Langkah 2: Setelah yakin tidak ada masalah, tingkatkan ke 6 bulan
add_header Strict-Transport-Security "max-age=15768000" always;
# Langkah 3: Full production (2 tahun + subdomains + preload)
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
# ============================================
# Preload List Submission
# ============================================
# Setelah HSTS aktif dengan preload directive,
# daftarkan situs ke HSTS Preload List:
# https://hstspreload.org
#
# Manfaat: Browser sudah tahu situs kamu HTTPS-only
# BAHKAN SEBELUM kunjungan pertama.
# Chrome, Firefox, Safari, Edge mendukung preload list.
Setelah situs kamu masuk ke HSTS Preload List, sangat sulit untuk dihapus. Pastikan kamu benar-benar yakin ingin menggunakannya. Jika sertifikat SSL kadaluarsa dan kamu tidak bisa memperbarui, pengunjung tidak akan bisa mengakses situs kamu karena browser menolak koneksi non-HTTPS. Selalu pastikan auto-renewal berfungsi sebelum submit ke preload list.
8. Testing dan Validasi SSL/TLS
Setelah mengkonfigurasi SSL/TLS, sangat penting untuk menguji dan memvalidasi bahwa konfigurasi benar-benar aman dan tidak ada celah yang bisa dieksploitasi.
# ============================================
# SSL/TLS Testing & Validation Commands
# ============================================
# 1. Cek sertifikat dari command line
openssl s_client -connect example.com:443 -servername example.com
# 2. Cek versi TLS yang didukung
# Test TLS 1.3
openssl s_client -connect example.com:443 -tls1_3
# Test TLS 1.2
openssl s_client -connect example.com:443 -tls1_2
# Cek apakah TLS 1.0/1.1 masih aktif (harusnya ditolak)
openssl s_client -connect example.com:443 -tls1
# Harus error: "no protocols available"
# 3. Lihat detail sertifikat
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| openssl x509 -text -noout
# 4. Cek expiry date
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| openssl x509 -noout -dates
# 5. Cek cipher suite yang digunakan
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| grep -i "cipher"
# 6. Test dengan nmap
nmap --script ssl-enum-ciphers -p 443 example.com
# 7. Scan untuk Heartbleed vulnerability
nmap --script ssl-heartbleed -p 443 example.com
# 8. Test dari browser
# Buka: https://www.ssllabs.com/ssltest/analyze.html?d=example.com
# Target: Grade A atau A+
| Tool | Penggunaan | Akses |
|---|---|---|
| SSL Labs (Qualys) | Testing menyeluruh: cipher suites, protocol support, certificate chain, vulnerabilities. Grade A+ adalah target ideal. | Web: ssllabs.com/ssltest |
| testssl.sh | CLI tool yang sangat lengkap untuk testing SSL/TLS. Dapat dijalankan di server lokal. | CLI: github.com/drwetter/testssl.sh |
| openssl s_client | Built-in di semua Linux. Berguna untuk test cepat koneksi dan sertifikat. | CLI: sudah tersedia di Linux |
| nmap ssl scripts | Port scanner dengan script khusus SSL/TLS untuk mendeteksi cipher lemah dan vulnerabilities. | CLI: nmap.org |
| Mozilla Observatory | Testing header keamanan termasuk HSTS, CSP, dan security headers lainnya. | Web: observatory.mozilla.org |
Untuk mendapatkan grade A+ di SSL Labs, pastikan:
1) Sertifikat valid dan tidak expired, 2) Hanya
TLS 1.2 dan 1.3 yang aktif, 3) Cipher suite yang aman saja,
4) OCSP stapling aktif, 5) HSTS aktif dengan
minimal max-age=31536000, 6) Tidak ada mixed content
(semua resource HTTPS), dan 7) DH parameters minimal 2048-bit.
9. Quiz: Uji Pemahamanmu
Jawab pertanyaan berikut untuk menguji pemahaman kamu tentang SSL/TLS. Pilih satu jawaban terbaik untuk setiap pertanyaan.