Skip to content

Pre-OpenSSL 1.1.1 left-overs for keylog_filename #150898

@robsdedude

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-SSLtype-featureA feature request or enhancement
    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions