GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-138252: Add support in SSL module for getting and setting TLS signature algorithms by ronf · Pull Request #138269 · python/cpython

Conversation

@ronf

@ronf ronf commented Aug 30, 2025 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: Add support in SSL module for getting and setting TLS signature algorithms #138252

📚 Documentation preview 📚: https://cpython-previews--138269.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ronf
Add support in SSL module for getting and setting TLS signature algor…
7361440
…ithms
@ronf
ronf requested review from AA-Turner, gpshead and picnixz as code owners August 30, 2025 17:49
@bedevere-app bedevere-app Bot added the awaiting review label Aug 30, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Aug 30, 2025
Add support in SSL module for getting and setting TLS signature algorithms #138252
Closed
blurb-it Bot and others added 2 commits August 30, 2025 17:58
@blurb-it
📜🤖 Added by blurb_it.
c58c025
@ronf
Fix documentation warnings
761be4c
@ronf

ronf commented Aug 30, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Hrm. The "AWS-LC" build failure seems to relate to it not finding the function SSL_CTX_set1_client_sigalgs_list. However, I don't see any sign of that only being in more recent OpenSSL releases. Is there something unusual about the version of OpenSSL used there?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronf

ronf commented Aug 30, 2025

Copy link
Copy Markdown
Contributor Author

Ah - I see AWS-LC combines code from BoringSSL and OpenSSL. I guess we'll need to find some way to detect AWS-LC and raise an exception if the call to set the client sigalgs is used, at least for whatever version of AWS-LC triggered this failure.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronf

ronf commented Aug 30, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I looked through the AWS-LC code and can confirm it doesn't appear to support SSL_CTX_set1_client_sigalgs_list, even in the latest version. However, I'm not really sure how in the code to test for AWS-LC at build time or run time (either in the main SSL module or in the unit tests). I found some references claiming OPENSSL_IS_AWSLC should exist as a preprocessor symbol, but I don't see any evidence of that being used in CPython at the moment.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ronf added 4 commits August 30, 2025 13:18
@ronf
Allow ConnectionResetError for handshake failures in sigalgs test code
c045a2c
@ronf
Attempt to fix missing support for setting client sigalgs in AWS-LC
2b336ed
@ronf
Missed a test in the AWS-LC client sigalgs fix
1a549b4
@ronf
Update TLS 1.3 section of SSL docs to reflect that sigalgs can be con…
b659110
…figured
@ronf

ronf commented Aug 31, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I decided to go ahead and code up an ssl.get_sigalgs() function which looks like the following:

>>> import ssl
>>> ssl.get_sigalgs()
['ecdsa_secp256r1_sha256', 'ecdsa_secp384r1_sha384', 'ecdsa_secp521r1_sha512',
 'ed25519', 'ed448', 'ecdsa_sha224', 'ecdsa_sha1', 'ecdsa_brainpoolP256r1tls13_sha256',
 'ecdsa_brainpoolP384r1tls13_sha384', 'ecdsa_brainpoolP512r1tls13_sha512', 'rsa_pss_rsae_sha256',
 'rsa_pss_rsae_sha384', 'rsa_pss_rsae_sha512', 'rsa_pss_pss_sha256', 'rsa_pss_pss_sha384',
 'rsa_pss_pss_sha512', 'rsa_pkcs1_sha256', 'rsa_pkcs1_sha384', 'rsa_pkcs1_sha512', 'rsa_pkcs1_sha224',
 'rsa_pkcs1_sha1', 'dsa_sha256', 'dsa_sha384', 'dsa_sha512', 'dsa_sha224', 'dsa_sha1']

It's not checked in yet, but I can do so if we decide to include it, at which point I'll go back and fill in docs and unit tests for it. It seems like it might be useful for a client/server to know the available signature algorithms that it can choose from, since it may vary depending on the OpenSSL implementation in use and what providers are loaded.

Like SSLContext.get_groups(), this method returns a list of strings. The only difference is that this is a global list of available signature algs dependent only on which OpenSSL providers are loaded, rather than being sensitive to state in the SSLContext such as the TLS min & max versions. That's why it ends up being a module-level function.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Sep 2, 2025

Copy link
Copy Markdown
Member

Is there something unusual about the version of OpenSSL used there?

As you observed, AWS-LC is a fork of BoringSSL & LibreSSL. We decided to try supporting other flavors of libssl implementations because it might come handy for some users that don't want to use OpenSSL.

I looked through the AWS-LC code and can confirm it doesn't appear to support SSL_CTX_set1_client_sigalgs_list, even in the latest version

If this is the case, I suggest one of the following to do:

  • Fix this upstream or collaborate with @WillChilds-Klein on this matter.
  • Detect at configure time whether this is supported or not by the host.
  • Use OPENSSL_IS_AWSLC as claimed. We don't use it currently because everything seems to work on all ssl implementations. If something is specific to OpenSSL, then I would suggest using this macro.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Sep 2, 2025
View reviewed changes

@picnixz picnixz left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. You could refactor server_sigalg and client_sigalg into a single function as follows:

static PyObject *
ssl_socket_signame_impl(PySSLSocket *socket,
                        enum py_ssl_server_or_client self_socket_type)
{
#if OPENSSL_VERSION_NUMBER >= 0x30500000L
    int ret;
    const char *sigalg;

    if (socket->ssl == NULL) {
        Py_RETURN_NONE;
    }
    ret = (socket->socket_type == self_socket_type)
        ? SSL_get0_signature_name(socket->ssl, &sigalg)
        : SSL_get0_peer_signature_name(socket->ssl, &sigalg);
    if (ret == 0) {
        Py_RETURN_NONE;
    }
    return PyUnicode_DecodeFSDefault(sigalg);
#else
    PyErr_SetString(PyExc_NotImplementedError,
                    "Getting sig algorithms requires OpenSSL 3.5 or later.");
    return NULL;
#endif
}

and then implement:

static PyObject *
_ssl__SSLSocket_client_sigalg_impl(PySSLSocket *self)
{
    return ssl_socket_signame_impl(self, PY_SSL_CLIENT);
}

static PyObject *
_ssl__SSLSocket_server_sigalg_impl(PySSLSocket *self)
{
    return ssl_socket_signame_impl(self, PY_SSL_SERVER);
}

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/ssl.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/ssl.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/ssl.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_ssl.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_ssl.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_ssl.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Library/2025-08-30-17-58-04.gh-issue-138252.CDiEby.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_ssl.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_ssl.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ronf

ronf commented Sep 2, 2025

Copy link
Copy Markdown
Contributor Author

If this is the case, I suggest one of the following to do:

  • Fix this upstream or collaborate with @WillChilds-Klein on this matter.
  • Detect at configure time whether this is supported or not by the host.
  • Use OPENSSL_IS_AWSLC as claimed. We don't use it currently because everything seems to work on all ssl implementations. If something is specific to OpenSSL, then I would suggest using this macro.

I was able to get OPENSSL_IS_AWSLC to work here. I used that in the SSL module and then used the following in the unit tests (with skipUnless):

CAN_SET_CLIENT_SIGALGS = "AWS-LC" not in ssl.OPENSSL_VERSION

With that, the tests are all passing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronf
Address review comments
bc84599
@ronf

ronf commented Sep 3, 2025

Copy link
Copy Markdown
Contributor Author

@picnixz, any thoughts on the proposed ssl.get_sigalgs() function? Should I go ahead and finish the work on that?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronf
Add function to SSL module to get all available TLS signature algorithms
2d47a6c
@ronf

ronf commented Sep 7, 2025

Copy link
Copy Markdown
Contributor Author

I had some time this weekend, so I've gone ahead and added support for ssl.get_sigalgs() to return a list of all available TLS signature algorithms in commit 2d47a6c. I've also updated issue #138252 to mention this function.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronf

ronf commented Sep 7, 2025

Copy link
Copy Markdown
Contributor Author

The failure here appears to be in whatsnew/3.15.pst not being able to see the new ssl.get_sigalgs function. That file has no problem seeing other things from the SSL module, though. Also, other documentation files seem to have no issue with it.

Any idea what might be happening here? Do I need an explicit import somewhere? I don't see any such thing for other module references in whatsnew.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Sep 7, 2025
View reviewed changes
Comment thread Doc/library/ssl.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_ssl.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_ssl.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_ssl.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ronf
Fix error in get_sigalgs() documentation and address review comments
0c07131
picnixz
picnixz reviewed Sep 7, 2025
View reviewed changes
Comment thread Modules/_ssl.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Sep 7, 2025
View reviewed changes
Comment thread Modules/_ssl.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

ronf added 2 commits September 7, 2025 07:58
@ronf
Switch get_sigalgs to use DecodeFSDefault instead of DecodeASCII.
aad7d47
@ronf
Switch get_groups() to DecodeFSDefault, and clean up error handling
2ec62c0
@ronf
Remove critical section from get_sigalgs() function
36733b9
@ronf

ronf commented Sep 7, 2025

Copy link
Copy Markdown
Contributor Author

@picnixz, Anything further you'd like me to change? I think I've covered all the current review comments.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Sep 7, 2025

Copy link
Copy Markdown
Member

No I think we're good. I'll have a final check tomorrow, and if needed, directly commit to your branch, and then merge it.

ronf reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz approved these changes Sep 7, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Sep 7, 2025
This was referenced Sep 8, 2025
Improve documentation of SSL module #138633
Open
Improve usage of _setSSLError in _ssl.c #138634
Open
gh-133879: Copyedit "What's New in Python 3.15": consistent periods and double blank lines #138635
Merged
@picnixz
Update ssl.__doc__
e43b937
@picnixz
picnixz enabled auto-merge (squash) September 8, 2025 08:31
@picnixz
picnixz merged commit 6401823 into python:main Sep 8, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 8, 2025
@vstinner

vstinner commented Sep 8, 2025

Copy link
Copy Markdown
Member

Would it be possible to mention the OpenSSL version requirements in the documentation?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Sep 8, 2025

Copy link
Copy Markdown
Member

That's what I plan to do (I'm actually working on it now): #138633.

vstinner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronf
ronf deleted the ssl-sigalg-support branch September 8, 2025 23:56
lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
@ronf @picnixz @lkollar
pythongh-138252: Add support in SSL module for getting and setting TL…
4429ba3
…S signature algorithms (python#138269)

The signature algorithms allowed for certificate-based client authentication or
for the server to complete the TLS handshake can be defined on a SSL context via
`ctx.set_client_sigalgs()` and `ctx.set_server_sigalgs()`.

With OpenSSL 3.4 or later, the list of available TLS algorithms can be retrieved
by `ssl.get_sigalgs()`.

With OpenSSL 3.5 or later, the selected signature algorithms can be retrieved from
SSL sockets via `socket.client_sigalg()` and `socket.server_sigalg()`.

This commit also partially amends 377b787
by using `PyUnicode_DecodeFSDefault` instead of `PyUnicode_DecodeASCII` in
`_ssl._SSLContext.get_groups`, so that functions consistently decode strings
obtained from OpenSSL.

---------

Co-authored-by: Bénédikt Tran <[email protected]>
@typenoob typenoob mentioned this pull request Oct 29, 2025
Update OpenSSL versions for CI and Windows #131423
Closed
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@picnixz picnixz picnixz approved these changes
@ZeroIntensity ZeroIntensity ZeroIntensity left review comments
@gpshead gpshead Awaiting requested review from gpshead gpshead is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@ronf @picnixz @vstinner @ZeroIntensity
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.