ArcLibrary

TLS (Transport Layer Security)

The de-facto standard for modern encrypted communication — HTTPS / SMTPS / IMAPS / DoT all run on it.

TLSEncryptionKeys
核心 · Key Idea

In one line: TLS sits on top of TCP and gives you confidentiality, integrity, and authentication. The two parties exchange a symmetric session key via certificates + public-key crypto, then encrypt all subsequent data with it. HTTPS / SMTPS / IMAPS / DoT / mTLS / gRPC all rely on it.

What it is#

TLS isn't a single protocol — it's a generic mechanism that wraps another protocol with an encrypted channel. Common uses:

ProtocolTLS-wrapped
HTTPHTTPS
SMTPSMTPS / STARTTLS
IMAPIMAPS
DNSDoT (DNS over TLS)
MQTTMQTTS

Mainstream versions: TLS 1.2 (older but still common) / TLS 1.3 (recommended — safer and faster).

Analogy#

打个比方 · Analogy

TLS is like a safe-deposit-box system:

  • The two sides securely exchange one common key during the handshake;
  • Every letter goes into a same-model safe and travels;
  • Even if the postman (ISP) holds the safe, they can't open it.

Key concepts#

Symmetric keySymmetric Key
Negotiated session key (AES); fast both encrypt/decrypt.
Asymmetric keyAsymmetric Key
Public/private key (RSA / ECDHE) used during handshake to safely deliver the symmetric key.
Cert chainCert Chain
Server cert → intermediate → root CA. The browser validates signatures along the chain.
PFSPerfect Forward Secrecy
Each session uses an ephemeral key (ECDHE); even if the long-term private key leaks later, past sessions remain safe.
0-RTT0-RTT
TLS 1.3 reuses prior session info to send data with zero handshake — fast but with replay risk.
mTLSMutual TLS
Both sides present certs; common in service-to-service auth and zero-trust networks.

How it works (TLS 1.3 simplified)#

TLS 1.3 dropped static-RSA key exchange, forces PFS, and compresses the handshake to 1-RTT.

Practical notes#

  • Prefer TLS 1.3. Disable 1.0 / 1.1 (PCI / ISO require this).
  • Auto-renew certs: Let's Encrypt + Caddy / Traefik / certbot — never renew by hand.
  • openssl s_client -connect host:443 -tls1_3 -servername host debugs TLS 1.3.
  • testssl.sh is an open-source scanner for site versions / ciphers / vulns.
  • mTLS: one cert per service → service mesh (Istio / Linkerd) auto-issues and rotates.
  • Never commit private keys to git. Production keys live in Vault / KMS / Secret Manager.

Easy confusions#

TLS
Standard since 1999, now at 1.3.
Modern usage should always say "TLS".
SSL
SSL 1/2/3 are TLS's predecessors — **all deprecated**.
"SSL certificate" is just a legacy phrase.

Further reading#