Your observation is insightful: certificates are indeed public information, and their contents (e.g., domain name, public key, issuer) are not inherently sensitive. However, encrypting the certificate and other handshake messages during the TLS 1.3 handshake serves critical security purposes beyond simply hiding the certificate itself. Here’s why encryption of the handshake matters:
1. Protects Handshake Integrity and Authentication
- While the certificate itself is public, the handshake messages that follow the key exchange (e.g., Certificate, CertificateVerify, Finished) include cryptographic proofs (e.g., signatures, MACs) that bind the handshake to the shared secret.
- If these messages were unencrypted, an attacker could:
- Modify the certificate (e.g., replace it with a malicious one).
- Tamper with the CertificateVerify message (which proves the server owns the private key).
- Manipulate the Finished message (which confirms the handshake was not altered).
- Encryption + authentication (via HMAC or AEAD) ensures these messages cannot be altered without detection.
2. Prevents Downgrade Attacks
- In older TLS versions (e.g., TLS 1.2), parts of the handshake (like the server’s certificate) were sent in plaintext. This allowed attackers to:
- Intercept and modify handshake parameters to force weaker protocols, cipher suites, or key exchange methods.
- In TLS 1.3, the entire handshake (after ServerHello) is encrypted. This prevents attackers from tampering with or observing the handshake, making downgrade attacks significantly harder.
3. Hides Metadata for Privacy
- While the certificate itself is public, encrypting the handshake hides metadata like:
- Which specific certificate is being used (e.g., SNI, ALPN extensions).
- The exact timing and structure of the handshake.
- This makes it harder for eavesdroppers to:
- Fingerprint the server (e.g., by observing which certificates are exchanged).
- Track user behavior (e.g., correlating encrypted traffic with specific websites).
- For example, if a user visits a site with a unique certificate, exposing it in plaintext could reveal their activity to a passive observer.
4. Ensures Forward Secrecy
- TLS 1.3 uses ephemeral Diffie-Hellman (DHE) key exchange for all handshakes. The derived keys are short-lived and discarded after the session ends.
- If the handshake were unencrypted, an attacker could record the handshake and later compromise the server’s long-term private key to:
- Decrypt past sessions (if the certificate’s private key was used directly for encryption).
- By encrypting the handshake with ephemeral keys, TLS 1.3 ensures forward secrecy: even if the server’s private key is compromised later, past sessions remain secure.
5. Simplifies Protocol Design
- Encrypting the entire handshake (post-ServerHello) simplifies the protocol by:
- Eliminating the need to distinguish between "sensitive" and "non-sensitive" handshake messages.
- Reducing attack surfaces (e.g., no unauthenticated handshake messages).
- This aligns with the principle of "encrypt-then-authenticate", which minimizes opportunities for vulnerabilities.
Why Not Leave the Certificate Unencrypted?
Even though certificates are public, exposing them in plaintext during the handshake introduces risks:
- Traffic Analysis: Observers can infer which services a client is connecting to.
- Replay Attacks: Unencrypted handshake messages could be replayed or manipulated.
- Middlebox Interference: Network devices (e.g., firewalls, proxies) might inspect or block traffic based on unencrypted handshake data.
By encrypting the entire handshake, TLS 1.3 ensures:
- Confidentiality: No handshake data is exposed to eavesdroppers.
- Integrity: All handshake messages are protected against tampering.
- Authentication: The server’s identity is cryptographically verified within the encrypted channel.
Summary
Encrypting the server certificate and other handshake messages in TLS 1.3 isn’t about hiding public information; it’s about protecting the cryptographic integrity of the handshake itself. This ensures:
- The client authenticates the server using tamper-proof data.
- The session key exchange remains secure against active and passive attackers.
- Forward secrecy and resistance to downgrade attacks are maintained.
Even though certificates are public, their role in the handshake requires protection to prevent attacks that could compromise the entire TLS session.