-
-
Notifications
You must be signed in to change notification settings - Fork 34k
gh-136306: Add support for SSL groups #136307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
662d66e
gh-136306: Initial cut at SSL groups support
ronf 9acb2c3
Fix regen and lint issues
ronf 03072c4
📜🤖 Added by blurb_it.
blurb-it[bot] 187ff2e
gh-136306: Address first round of comments
ronf 452bdec
gh-136306: Add back indentation of example
ronf 9b4066b
gh-136306: Handle another allocation failure in get_groups()
ronf a6ad433
gh-136306: Address additional review comments
ronf aecc96b
gh-136306: Fix method references in whatsnew entry.
ronf 05c75a5
gh-136306: Add missing documentation for SSLSocket.group()
ronf 304c223
gh-136306: Address additional review comments
ronf b516200
gh-136306: Minor doc updates
ronf e0fdd25
gh-136306: Missed one
ronf 35a3ae0
gh-136306: Address additional review comments
ronf e0baf56
Add checks that cipher() and group() return None on handshake failure
ronf c5a1146
Merge branch 'main' into ssl-group-support
ronf 5e626a6
gh-136306: Regenerate clinic signature to fix missing end fo line
ronf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1290,6 +1290,13 @@ SSL sockets also have the following additional methods and attributes: | |
|
|
||
| .. versionadded:: 3.5 | ||
|
|
||
| .. method:: SSLSocket.group() | ||
|
|
||
| Return the group used for doing key agreement on this connection. If no | ||
| connection has been established, returns ``None``. | ||
|
|
||
| .. versionadded:: next | ||
|
|
||
| .. method:: SSLSocket.compression() | ||
|
|
||
| Return the compression algorithm being used as a string, or ``None`` | ||
|
|
@@ -1647,6 +1654,25 @@ to speed up repeated connections from the same clients. | |
|
|
||
| .. versionadded:: 3.6 | ||
|
|
||
| .. method:: SSLContext.get_groups(*, include_aliases=False) | ||
|
|
||
| Get a list of groups implemented for key agreement, taking into | ||
| account the current TLS :attr:`~SSLContext.minimum_version` and | ||
| :attr:`~SSLContext.maximum_version` values. For example:: | ||
|
|
||
| >>> ctx = ssl.create_default_context() | ||
| >>> ctx.minimum_version = ssl.TLSVersion.TLSv1_3 | ||
| >>> ctx.maximum_version = ssl.TLSVersion.TLSv1_3 | ||
| >>> ctx.get_groups() # doctest: +SKIP | ||
| ['secp256r1', 'secp384r1', 'secp521r1', 'x25519', 'x448', ...] | ||
|
|
||
| By default, this method returns only the preferred IANA names for the | ||
| available groups. However, if the ``include_aliases`` parameter is set to | ||
| :const:`True` this method will also return any associated aliases such as | ||
| the ECDH curve names supported in older versions of OpenSSL. | ||
|
|
||
| .. versionadded:: next | ||
|
|
||
| .. method:: SSLContext.set_default_verify_paths() | ||
|
|
||
| Load a set of default "certification authority" (CA) certificates from | ||
|
7440
|
@@ -1672,6 +1698,19 @@ to speed up repeated connections from the same clients. | |
| TLS 1.3 cipher suites cannot be disabled with | ||
| :meth:`~SSLContext.set_ciphers`. | ||
|
|
||
| .. method:: SSLContext.set_groups(groups) | ||
|
|
||
| Set the groups allowed for key agreement for sockets created with this | ||
| context. It should be a string in the `OpenSSL group list format | ||
| <https://docs.openssl.org/master/man3/SSL_CTX_set1_groups_list/>`_. | ||
gpshead marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .. note:: | ||
|
|
||
| When connected, the :meth:`SSLSocket.group` method of SSL sockets will | ||
| return the group used for key agreement on that connection. | ||
|
|
||
| .. versionadded:: next | ||
|
|
||
| .. method:: SSLContext.set_alpn_protocols(protocols) | ||
|
|
||
| Specify which protocols the socket should advertise during the SSL/TLS | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Library/2025-07-04-23-45-00.gh-issue-136306.O1YLIU.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| :mod:`ssl` can now get and set groups used for key agreement. | ||
picnixz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.