Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Vendor: Python Software Foundation · https://www.python.org/ · pkg:generic/python · Last reviewed 2026-12-05 · History

Summary

  • Python linked against OpenSSL 3.5 or later uses OpenSSL’s default group list, which starts with the hybrid group X25519MLKEM768, so it is default; with an earlier OpenSSL it is classical.
  • From Python 3.15, SSLContext.set_groups() lets the program choose groups, so classical groups can be disabled by the author; before 3.15 the ssl module has no such method for clients.1
  • The standard library has no public-key signing API of its own.
  • The Python project has published no commitment about post-quantum support (checked 2026-12-05).

On Python 3.15 or later, call ctx.set_groups("X25519MLKEM768") to allow only the hybrid group.1

Cryptographic operations

  • TLS connections (client or server, ssl.SSLContext): from 3.15, set_groups(groups) will “set the groups allowed for key agreement for sockets created with this context. It should be a string in the OpenSSL group list format.” SSLSocket.group() returns “the group used for doing key agreement on this connection”.1
  • SSLContext.set_ecdh_curve() takes one curve name; “this setting doesn’t apply to client sockets”.1
  • With no groups set, OpenSSL’s default list applies.

Versions

Change Version Package URL Source
SSLContext.set_groups(), get_groups() and SSLSocket.group() added 3.15 pkg:generic/python@3.15.0 1

Check the OpenSSL in use: python3 -c 'import ssl; print(ssl.OPENSSL_VERSION)'.

Configuration

Enabling PQC

Nothing needed with OpenSSL 3.5 or later. To confirm the negotiated group on 3.15 or later:

import socket, ssl
ctx = ssl.create_default_context()
with ctx.wrap_socket(socket.create_connection(("example.com", 443)), server_hostname="example.com") as s:
    print(s.group())

Disabling classical algorithms

ctx = ssl.create_default_context()
ctx.set_groups("X25519MLKEM768")

Servers without the group fail the handshake. Before 3.15 there is no way to set a client’s group list; whether a build reads OpenSSL’s configuration file is unverified (checked 2026-12-05).

Proofs

References

  1. Python documentation, ssl module, SSLContext.set_groups, SSLContext.set_ecdh_curve and SSLSocket.group. https://docs.python.org/3/library/ssl.html (accessed 2026-12-05) ↩ ↩2 ↩3 ↩4 ↩5


Edit: Python

If you give an email address it is recorded publicly as the author of the commit, and GitHub will link the commit to your account if that address belongs to one.

Edits are reviewed before they appear. By submitting you release your contribution under CC BY-SA 4.0. Read the editorial guidelines first.

This site uses Just the Docs, a documentation theme for Jekyll.