Documentation
Docs
Originally this started off with me finding the docs for ssl.create_default_context stating
When
keylog_filenameis supported and the environment variableSSLKEYLOGFILEis 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:
| # 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.