<Python 3.16 Adds TLS Encrypted Client Hello (ECH) — What It Actually Hides From Network Observers
Python 3.16.0a2, released November 10, 2026, quietly adds something more interesting than another syntax tweak: the ssl module can now negotiate TLS Encrypted Client Hello (ECH), provided it's built against OpenSSL 4.0 or newer. If you've never run into ECH before, the short version is: it closes one of the last plaintext leaks left in modern HTTPS. The slightly longer version is worth understanding, because "encrypts the hello" undersells what's actually going on.
This post explains what ECH hides, what it doesn't, and walks through a real example of fetching an ECH configuration from DNS and using it to open a connection.
The leak ECH closes: SNI
When your Python process opens a TLS connection, the very first message it sends — the ClientHello — includes a field called Server Name Indication (SNI). SNI tells the server which hostname you're trying to reach, because a single IP address might be hosting hundreds of different sites behind a load balancer or CDN.
The problem: the ClientHello is sent before encryption is set up. TLS 1.3 encrypts almost everything else about your session, but that first message — including the real hostname — goes out in plaintext. Anyone who can see your traffic (your ISP, a Wi-Fi operator, a transparent proxy, a state-level censor) can read exactly which site you're connecting to, even though they can't read what you send or receive afterward. This is how network-level domain filtering and "who's talking to whom" surveillance mostly works today — not by decrypting your traffic, but by reading the one field TLS never bothered to hide.
ECH fixes this by encrypting the real ClientHello (the "inner" hello, containing your real SNI) inside a second, outer ClientHello. The outer one still goes out in plaintext, but it carries a generic placeholder hostname called the public name — something like the CDN's own domain — instead of the site you're actually visiting. An observer sees a TLS handshake to the public name. They do not see which of the (possibly thousands of) sites behind that CDN edge you actually reached.
What ECH does not hide
It's worth being precise here, because "encrypts the hello" invites overclaiming:
- The destination IP is still visible. ECH only helps when many hostnames share an IP/edge — which is true for most CDN-fronted sites, but not for a server with its own dedicated address.
- Traffic timing and volume are still visible. ECH doesn't do anything about traffic analysis.
- Your DNS query might still leak the hostname — unless you're also using encrypted DNS (DoH/DoT), the DNS lookup for the real hostname can leak it before TLS even starts. ECH and encrypted DNS are meant to be deployed together; one without the other still leaves a gap.
- The server operator always knows exactly who connected — ECH is about hiding your destination from network observers in the middle, not from the destination itself.
How the encryption actually works
ECH relies on a public key the server publishes in DNS, in an HTTPS (or legacy SVCB) resource record, as one of several typed parameters called SvcParams. The relevant one is SvcParamKey 5, named ech, and it contains a base64-encoded ECHConfigList — effectively "here's my current public key and the cipher suites I support for ECH, go encrypt your real ClientHello with this."
Your client fetches that DNS record, uses the published public key to encrypt the real (inner) ClientHello via HPKE (Hybrid Public Key Encryption), and wraps it inside the outer ClientHello that gets sent on the wire. Only the server — holding the matching private key — can decrypt the inner hello and see your real SNI.
A worked example: fetching an ECH config and using it
Here's the end-to-end flow in Python: check for ECH support, pull the ECH config out of a live DNS HTTPS record with dnspython, and feed it into an SSLContext.
Step 1 — confirm your build actually has ECH support. This needs OpenSSL 4.0+ under the hood; a 3.16 build linked against an older OpenSSL simply won't expose the new API surface.
import ssl
print(ssl.OPENSSL_VERSION)
# e.g. "OpenSSL 4.0.0 1 Oct 2026"
# <!-- verify: confirm the exact attribute/method name against the 3.16 changelog entry;
# different pre-release builds have used different names for ECH support checks
# before the API stabilized. -->
print(hasattr(ssl.SSLContext, "set_ech_config"))Step 2 — pull the ECH config out of DNS. SvcParamKey 5 is ech in the HTTPS/SVCB SvcParams registry. A resolver that understands typed SVCB params (like dnspython 2.x) hands it back decoded.
import dns.resolver
def fetch_ech_config(hostname: str) -> bytes | None:
answer = dns.resolver.resolve(hostname, "HTTPS")
for rr in answer:
params = getattr(rr, "params", {})
ech_param = params.get(5) # SvcParamKey 5 == "ech"
if ech_param is not None:
return ech_param.ech # raw ECHConfigList bytes
return None
ech_config = fetch_ech_config("example-ech-enabled-site.com")
if ech_config is None:
print("No ECH config published for this host — falls back to plain SNI.")Step 3 — hand it to the SSL context and connect.
import socket
import ssl
hostname = "example-ech-enabled-site.com"
ctx = ssl.create_default_context()
if ech_config is not None:
# <!-- verify: exact ssl.SSLContext API name/signature for loading an ECHConfigList
# in 3.16 — this call shape is illustrative; check the real changelog entry
# linked in this post's CTA before shipping code against it. -->
ctx.set_ech_config(ech_config)
with socket.create_connection((hostname, 443)) as sock:
with ctx.wrap_socket(sock, server_hostname=hostname) as tls_sock:
print("Negotiated:", tls_sock.version())
print("ECH accepted by server:", getattr(tls_sock, "ech_accepted", "unknown"))If the server's real ECH key doesn't match what you fetched (say, DNS was cached and the server already rotated keys), TLS 1.3's ECH design has a documented fallback: the server decrypts what it can, detects the mismatch, and sends back its current config so the client can retry — rather than just failing the connection outright. That retry-on-key-mismatch behavior is part of why ECH key rotation doesn't require perfectly synchronized DNS propagation to avoid breaking clients.
Why this matters for anything you build
If you write HTTP clients, scrapers, proxies, or anything that talks TLS directly instead of going through requests/httpx defaults, this is the first release where the standard library gives you a path to ECH without reaching for a third-party TLS binding. Expect requests, httpx, and aiohttp to pick this up opportunistically over the next few minor releases as their maintainers decide how (and whether) to expose it at the high-level API, rather than leaving it buried in ssl.SSLContext.
For now, if you're building anything privacy-sensitive — a Tor-adjacent tool, a research scraper that shouldn't tip off which specific pages it's hitting behind a shared CDN, or just an app you want to be honest with users about — this is worth testing against a real ECH-enabled origin (several major CDNs already publish ECH configs) rather than waiting for a wrapper library to catch up.

Experienced DevOps Engineer proficient in Python, Docker, Kubernetes, CI/CD, and cloud technologies. Specialized in automating processes and building scalable infrastructure for seamless development and deployment.


