FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-34271: Add ssl debugging helpers (GH-10031) by tiran · Pull Request #10031 · python/cpython · GitHub

Repository navigation

bpo-34271: Add ssl debugging helpers (GH-10031) - #10031

Merged
tiran merged 2 commits into
python:masterfrom
tiran:bpo-34271-ssldebug
May 31, 2019
Merged

tiran merged 2 commits into
python:masterfrom
tiran:bpo-34271-ssldebug

Conversation

tiran commented Oct 21, 2018 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

The ssl module now can dump key material to a keylog file and trace TLS
protocol messages with a tracing callback. The default and stdlib
contexts also support SSLKEYLOGFILE env var.

  • API review
  • whatsnew entry
  • More tests

https://bugs.python.org/issue34271

Copy link
Copy Markdown

I made a first test setting the env variable SSLKEYLOGFILE from python and creating the file from there as well. Currently the ~ resolution does not seem to work, but besides that using the simple client socket example from the ssl docs I was able to grab the keys and log them into the file the env variable was pointing to. I was on a Mac and installed openssl@1.1 via homebrew.

tiran commented Oct 24, 2018

Copy link
Copy Markdown
Member Author

The SSLKEYLOGFILE only works, if you

  • have OpenSSL 1.1.1 installed. OpenSSL 1.1.0 or 1.0.2 don't have a keylog callback API. Linux distributions like Debian and Fedora just started to include 1.1.1 in their latest test versions.
  • use ssl.create_default_context(). A custom ssl.SSLContext doesn't use SSLKEYLOGFILE.

I decided against expanding ~ to user's home directory, because neither curl nor NSS expand them.

Copy link
Copy Markdown

I wrote some basic examples showing this works very well. Thanks to https://github.com/jmfrank63/ssl-examples/commits?author=nikosgraser for providing the requests example.

tiran force-pushed the bpo-34271-ssldebug branch 3 times, most recently from e938b5b to 3f17e9f Compare May 29, 2019 09:42

tiran commented May 29, 2019

Copy link
Copy Markdown
Member Author

@zooba Could you please do me a favor and try the patch on Windows? One of the test cases is failing on Windows and I don't understand why.

======================================================================
FAIL: test_keylog_env (test.test_ssl.TestSSLDebug)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\cpython\lib\test\test_ssl.py", line 4488, in test_keylog_env
    self.assertEqual(ctx.keylog_filename, support.TESTFN)
AssertionError: None != '@test_4872_tmp'
----------------------------------------------------------------------

tiran changed the title [WIP] bpo-34271: Add ssl debugging helpers bpo-34271: Add ssl debugging helpers May 29, 2019
tiran force-pushed the bpo-34271-ssldebug branch 4 times, most recently from ea3fd14 to 8bbb6df Compare May 30, 2019 12:50

tiran commented May 30, 2019

Copy link
Copy Markdown
Member Author

@zooba One Windows test case was failing because ignore_environment flag was set. I'm now skipping the test case if the flag is set.

tiran requested a review from vstinner May 30, 2019 20:55
Comment thread Doc/library/ssl.rst Outdated
tiran added 2 commits May 31, 2019 11:25
The ssl module now can dump key material to a keylog file and trace TLS
protocol messages with a tracing callback. The default and stdlib
contexts also support SSLKEYLOGFILE env var.
The msg_callback and related enums are now private members. The feature
is designed for internal debugging and not for end users.

Signed-off-by: Christian Heimes <christian@python.org>
tiran force-pushed the bpo-34271-ssldebug branch from 1894a5e to 9bbf7a4 Compare May 31, 2019 09:25
tiran changed the title bpo-34271: Add ssl debugging helpers bpo-34271: Add ssl debugging helpers (GH-10031) May 31, 2019
tiran merged commit c7f7069 into python:master May 31, 2019
tiran deleted the bpo-34271-ssldebug branch May 31, 2019 09:44
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
The ssl module now can dump key material to a keylog file and trace TLS
protocol messages with a tracing callback. The default and stdlib
contexts also support SSLKEYLOGFILE env var.

The msg_callback and related enums are private members. The feature
is designed for internal debugging and not for end users.

Signed-off-by: Christian Heimes <christian@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL