Skip to content
Quantum Aether/Post-quantum TLS in Python (ssl, requests, httpx): it depends on OpenSSL · Quantum Aether
Live platformالعربية

Post-quantum TLS in Python (ssl, requests, httpx): it depends on OpenSSL

Updated:

Scan your site now, free

Domain or HTTP(S) URL. HTTPS port 443 is checked; paths and pasted URL ports are not scanned.

Python's ssl module, and everything built on it (urllib, requests, httpx, aiohttp, uvicorn and gunicorn with TLS), uses the OpenSSL library Python was linked to. Since OpenSSL 3.5, OpenSSL's defaults offer the hybrid X25519MLKEM768. So the question is not "which Python?" but "which OpenSSL?".

1. Check which OpenSSL your Python uses

python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"

We tested the same Python 3.12.16 two ways. Linked to OpenSSL 3.0.2 (Ubuntu 22.04's system Python), it connected to a server with plain x25519. Linked to OpenSSL 3.5.9, it negotiated X25519MLKEM768, with no code change. The python.org installers for Windows and macOS moved from OpenSSL 3.0 to 3.5.9 in 2026 (for example Python 3.13.16, released 30 September 2026), and the Pythons that uv installs ship with 3.5 as well. Linux distribution Pythons use the system OpenSSL (3.0 on Ubuntu 22.04 and 24.04).

2. Python 3.15: control and read the group

Python 3.15 (October 2026) adds SSLContext.set_groups(), SSLContext.get_groups() and SSLSocket.group(). Earlier versions have only set_ecdh_curve(), which takes a single classical curve. Watch out for servers that call set_ecdh_curve('prime256v1'): in our test it removed the hybrid group, and a client offering X25519MLKEM768 ended up on secp256r1. Delete the call and keep the defaults.

import ssl, socket
ctx = ssl.create_default_context()
# optional, Python 3.15+: hybrid first, classical fallback
ctx.set_groups("X25519MLKEM768:X25519:prime256v1")
with socket.create_connection(("example.com", 443)) as s:
    with ctx.wrap_socket(s, server_hostname="example.com") as t:
        print(t.version(), t.group())   # TLSv1.3 X25519MLKEM768

Like other "hardening" lists, set_groups("X25519:prime256v1") removes the hybrid group: in our test the same connection then used x25519.

3. Behind a proxy, the proxy decides

Most Python web apps (Django, Flask, FastAPI) sit behind nginx, a load balancer or a CDN that terminates TLS. Browsers never talk TLS to Python directly, so configure that layer (nginx, AWS ALB/CloudFront). The OpenSSL version still matters for your outgoing requests to APIs.

Verify

On Python 3.15, use the snippet above. On older versions, check ssl.OPENSSL_VERSION is 3.5 or newer, or run the free scan against your site; grade A means TLS 1.3 with a hybrid post-quantum key exchange. More ways: how to check any website.

Sources: Python 3.15 "What's New" (ssl) and ssl module docs; OpenSSL 3.5 release notes; our own tests with Python 3.12.16 and 3.15.2. Checked 2026-11-10.

Scan your site now, free

Domain or HTTP(S) URL. HTTPS port 443 is checked; paths and pasted URL ports are not scanned.