Skip to content

Pre-OpenSSL 1.1.1 left-overs for keylog_filename #150898

Closed

Description

@robsdedude

Documentation

Docs

Originally this started off with me finding the docs for ssl.create_default_context stating

When keylog_filename is supported and the environment variable SSLKEYLOGFILE is set, create_default_context() enables key logging.

So I looked at keylog_filename's docs to try to find out why or how it could be unsupported. Nothing 🤔

After a while I figured looking at older versions might give me a hint. And indeed in Python 3.9's docs it says

Note: This features requires OpenSSL 1.1.1 or newer.

Since Python 3.10 the ssl module requires OpenSSL 1.1.1 or newer. So that limitation has been lifted and no more "when ... is supported" is needed.

Code

Turns out, this does not just affect the docs:

cpython/Lib/ssl.py

Lines 723 to 727 in 57d4446

# OpenSSL 1.1.1 keylog file
if hasattr(context, 'keylog_filename'):
keylogfile = os.environ.get('SSLKEYLOGFILE')
if keylogfile and not sys.flags.ignore_environment:
context.keylog_filename = keylogfile

The implementation itself still performs the availability check, which since 3.10 would always evaluate to True. So that code can be cleaned up, too.

Linked PRs

Activity

  1. changed the title [-]Pre-OpenSSL 1.1.1 left-overs[/-] [+]Pre-OpenSSL 1.1.1 left-overs for `keylog_filename`[/+] on Jun 4, 2026
  2. added
    type-featureA feature request or enhancement
    stdlibStandard Library Python modules in the Lib/ directory
    and removed
    docsDocumentation in the Doc dir
    on Jun 4, 2026
  3. added a commit that references this issue on Jun 9, 2026
  4. added a commit that references this issue on Jun 17, 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

    stdlibStandard Library Python modules in the Lib/ directorytopic-SSLtype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions