Skip to content

TLSv1.3 should be among possible return values of ssl.SSLSocket.version #154727

Open

Description

@mimi89999

Documentation

Currently the https://docs.python.org/3.15/library/ssl.html#ssl.SSLSocket.version doc states:

Return the actual SSL protocol version negotiated by the connection as a string, or None if no secure connection is established. As of this writing, possible return values include "SSLv2", "SSLv3", "TLSv1", "TLSv1.1" and "TLSv1.2". Recent OpenSSL versions may define more return values.

I got TLSv1.3:

>>> import socket
... import ssl
... 
... hostname = 'lebihan.pl'
... context = ssl.create_default_context()
... 
... with socket.create_connection((hostname, 443)) as sock:
...     with context.wrap_socket(sock, server_hostname=hostname) as ssock:
...         print(ssock.version())
...         
TLSv1.3

Linked PRs

Activity

  1. StanFromIreland commented on Jul 26, 2026

    @StanFromIreland
    Member

    Note that it says "possible" return values, not "all" return values, and it explicitly adds that "recent OpenSSL versions may define more return values." I don't think we need to enumerate every possible return value here.

  2. mimi89999 commented on Jul 26, 2026

    @mimi89999
    Author

    I get not wanting a full list, but TLSv1.3 isn't just another possible value. It's the only one missing for full coverage, and adding it removes any ambiguity.

  3. picnixz commented on Jul 27, 2026

    @picnixz
    Member

    We require OpenSSL 1.1.1 dor the minimum requirement. If TLSv1.3 is present there (i do not remember) we can add it otherwise we do not.

  4. mimi89999 commented on Jul 27, 2026

    @mimi89999
    Author
  5. picnixz commented on Jul 27, 2026

    @picnixz
    Member

    I guess we can add it then!

  6. removed
    pendingThe issue will be closed if no feedback is provided
    on Jul 27, 2026
  7. picnixz commented on Jul 27, 2026

    @picnixz
    Member

    However in OSSL 4, IIRC some are removed so we should way "more recent may define more or less"

  8. added a commit that references this issue on Jul 27, 2026
  9. nightcityblade commented on Jul 27, 2026

    @nightcityblade

    Hi, I'd like to work on this. I'll submit a PR shortly.

  10. picnixz commented on Jul 27, 2026

    @picnixz
    Member

    Let's first ask if the OP wants to, this is the minimal courtesy. cc @mimi89999

  11. mimi89999 commented on Jul 27, 2026

    @mimi89999
    Author

    Thanks. I added it in #154785

  12. mimi89999 commented on Jul 28, 2026

    @mimi89999
    Author

    I've thought about this more and I'd like to walk back my suggestion.

    SSLSocket.version() just forwards to SSL_get_version(), so the string isn't defined by CPython at all. It comes from whatever TLS library Python is linked against, which can vary by distribution and version. That means the docs can't really pin down the set of values.

    So instead of adding TLSv1.3 to the list, it might be better to say the value is produced by the underlying library and link to its docs:

    https://docs.openssl.org/master/man3/SSL_get_version/#return-values

    Listing the values is what made me assume they were exhaustive in the first place 😅, so making the indirection visible seems more useful than keeping a list.

  13. added a commit that references this issue on Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirtopic-SSL

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions