Home » SSL/TLS Deep Dive: Handshake, Certificates และ Best Practices
SSL/TLS Deep Dive: Handshake, Certificates และ Best Practices
SSL/TLS Deep Dive: Handshake, Certificates และ Best Practices
SSL/TLS (Secure Sockets Layer / Transport Layer Security) เป็น protocol ที่ encrypt การสื่อสารระหว่าง client และ server ผ่าน internet ป้องกัน eavesdropping, tampering และ forgery TLS 1.3 เป็นเวอร์ชันล่าสุดที่เร็วและปลอดภัยกว่า TLS 1.2 ทุก website ที่ใช้ HTTPS ใช้ TLS
SSL/TLS เป็น พื้นฐานของ internet security ทุก website, API, email, VPN ใช้ TLS การเข้าใจ TLS handshake, certificate chain และ cipher suites ช่วยให้ troubleshoot connection issues, configure secure servers และ detect man-in-the-middle attacks ได้
SSL vs TLS Versions
| Version |
ปี |
สถานะ |
หมายเหตุ |
| SSL 2.0 |
1995 |
Deprecated (insecure) |
ห้ามใช้ — มี vulnerability หลายตัว |
| SSL 3.0 |
1996 |
Deprecated (POODLE) |
ห้ามใช้ — POODLE attack |
| TLS 1.0 |
1999 |
Deprecated |
ห้ามใช้ — BEAST, compliance issues |
| TLS 1.1 |
2006 |
Deprecated |
ห้ามใช้ — ไม่ PCI DSS compliant |
| TLS 1.2 |
2008 |
Current (widely used) |
ปลอดภัย ถ้า config ถูกต้อง |
| TLS 1.3 |
2018 |
Latest (recommended) |
เร็วที่สุด + ปลอดภัยที่สุด |
TLS 1.2 Handshake
| Step |
Direction |
Action |
| 1. Client Hello |
Client → Server |
Supported TLS versions, cipher suites, random, SNI |
| 2. Server Hello |
Server → Client |
Chosen TLS version, cipher suite, random |
| 3. Certificate |
Server → Client |
Server certificate (+ chain) |
| 4. Server Key Exchange |
Server → Client |
DH parameters (if DHE/ECDHE) |
| 5. Server Hello Done |
Server → Client |
Server done sending |
| 6. Client Key Exchange |
Client → Server |
Pre-master secret (encrypted with server pubkey) หรือ DH public |
| 7. Change Cipher Spec |
Both |
Switch to encrypted communication |
| 8. Finished |
Both |
Verify handshake integrity |
TLS 1.2 = 2 round trips (2-RTT) ก่อนส่ง data ได้
TLS 1.3 Handshake (1-RTT)
| Step |
Direction |
Action |
| 1. Client Hello |
Client → Server |
Supported versions, cipher suites, key shares (ECDHE) |
| 2. Server Hello + Encrypted Extensions + Certificate + Finished |
Server → Client |
ทุกอย่างรวมใน 1 message (encrypted ตั้งแต่นี้) |
| 3. Client Finished |
Client → Server |
Verify + start sending data |
TLS 1.3 = 1 round trip (1-RTT), 0-RTT resumption supported (เร็วกว่า 1.2 มาก)
TLS 1.2 vs TLS 1.3
| Feature |
TLS 1.2 |
TLS 1.3 |
| Handshake RTT |
2-RTT |
1-RTT (0-RTT resumption) |
| Key Exchange |
RSA, DHE, ECDHE |
ECDHE only (forward secrecy mandatory) |
| Cipher Suites |
37+ (many insecure) |
5 only (all secure) |
| Removed |
– |
RSA key exchange, CBC mode, RC4, SHA-1, DES, 3DES |
| Encryption |
Starts after handshake |
Encrypted from Server Hello |
| Forward Secrecy |
Optional (depends on cipher) |
Mandatory (always ECDHE) |
Certificate Chain
| Level |
Certificate |
ใครออก |
| Root CA |
Self-signed root certificate |
CA ออกให้ตัวเอง (อยู่ใน trust store) |
| Intermediate CA |
ลงนามโดย Root CA |
Root CA ลงนาม |
| Server Certificate |
ลงนามโดย Intermediate CA |
Intermediate CA ลงนาม |
Client verify: Server cert → signed by Intermediate → signed by Root (ใน trust store) = trusted
Certificate Types
| Type |
Validation |
เหมาะกับ |
ราคา |
| DV (Domain Validation) |
ตรวจ domain ownership เท่านั้น |
Blog, personal site |
ฟรี (Let’s Encrypt) – $50/ปี |
| OV (Organization Validation) |
ตรวจ domain + organization |
Business websites |
$50-200/ปี |
| EV (Extended Validation) |
ตรวจ domain + org + legal entity |
Banks, e-commerce |
$100-500/ปี |
| Wildcard |
*.domain.com |
หลาย subdomains |
$50-500/ปี |
| SAN/Multi-Domain |
หลาย domains ใน cert เดียว |
Multiple domains |
$100-400/ปี |
Common TLS Issues
| Issue |
สาเหตุ |
วิธีแก้ |
| Certificate expired |
ลืม renew certificate |
Auto-renew (certbot, ACME) |
| Incomplete chain |
ไม่ส่ง intermediate cert |
Configure full chain ใน server |
| Hostname mismatch |
Cert CN/SAN ไม่ตรงกับ domain |
ออก cert ที่มี correct SAN |
| Weak cipher |
ใช้ cipher suite ที่ insecure |
Disable weak ciphers, use TLS 1.2+ |
| Mixed content |
HTTPS page load HTTP resources |
ใช้ HTTPS ทุก resource |
| HSTS not set |
ไม่ force HTTPS |
Set Strict-Transport-Security header |
Best Practices
| Practice |
รายละเอียด |
| TLS 1.3 preferred |
Enable TLS 1.3 + TLS 1.2 fallback (disable 1.0/1.1) |
| Forward secrecy |
ใช้ ECDHE cipher suites เท่านั้น |
| Auto-renew certs |
Let’s Encrypt + certbot auto-renewal (ฟรี) |
| Full chain |
Configure server ส่ง intermediate certs ด้วย |
| HSTS |
Strict-Transport-Security: max-age=31536000; includeSubDomains |
| OCSP Stapling |
Server staple OCSP response (ลด latency, เพิ่ม privacy) |
| CT (Certificate Transparency) |
Monitor CT logs สำหรับ unauthorized certs |
| Test with SSL Labs |
ssllabs.com/ssltest → เป้าหมาย Grade A+ |
ทิ้งท้าย: TLS = Internet Security Foundation
TLS encrypt ทุกการสื่อสารบน internet TLS 1.3 = 1-RTT, forward secrecy mandatory, 5 secure cipher suites Certificate chain: Root → Intermediate → Server Let’s Encrypt = free DV certs + auto-renewal HSTS + OCSP stapling + full chain + TLS 1.3 = Grade A+
อ่านเพิ่มเติมเกี่ยวกับ DNS Security DNSSEC และ DDoS Protection ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com