HTTPS 只不过是运行在一条 TLS 加密通道内的 HTTP。 TLS(Transport Layer Security)给你三项保证:机密性(confidentiality)(流量被加密)、完整性(integrity)(它无法被篡改而不被察觉)和认证(authentication)(你确实在与证书中所指名的服务器通信)。它在任何 HTTP 被发送之前,通过一次**握手(handshake)**协商完成:
Client Server
│──── ClientHello ──────────────────────▶│ (TLS versions, cipher suites, random)
│◀─── ServerHello + Certificate ─────────│ (chosen cipher + cert with public key)
│ │
│ verify cert against a trusted CA │
│ agree on keys (e.g. ECDHE key exchange)│
│ │
│──── Finished (encrypted) ──────────────▶│
│◀─── Finished (encrypted) ───────────────│
│========= encrypted application data ====│ (now HTTP flows, encrypted)
