Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keylog_filename triggering error when SSLKEYLOGFILE is not set #2015

Closed
mattbasta opened this issue Oct 3, 2020 · 3 comments · Fixed by #2016
Closed

keylog_filename triggering error when SSLKEYLOGFILE is not set #2015

mattbasta opened this issue Oct 3, 2020 · 3 comments · Fixed by #2016

Comments

@mattbasta
Copy link

Subject

Requests are failing with the error:

urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

The line that raises this exception is the following (at the bottom of the stacktrace):

File "/Users/basta/.local/share/virtualenvs/venv-OmZ6DiXY/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 302, in create_urllib3_context
    context.keylog_filename = os.environ.get("SSLKEYLOGFILE")

Editing this file to print os.environ.get("SSLKEYLOGFILE") shows that this is empty.

This issue started happening after upgrading from Python 3.7 to 3.8.

Environment

This issue is happening for me on macOS Catalina 10.15.2.

import platform
import urllib3

print("OS", platform.platform())
print("Python", platform.python_version())
print("urllib3", urllib3.__version__)

returns

>>> import platform
>>> import urllib3
>>>
>>> print("OS", platform.platform())
OS macOS-10.15.2-x86_64-i386-64bit
>>> print("Python", platform.python_version())
Python 3.8.5
>>> print("urllib3", urllib3.__version__)
urllib3 1.25.10

Steps to Reproduce

This issue is always reproducible when making any requests using the stripe-python library. I don't have access to other machines to try to reproduce it elsewhere. However, it does not occur in my production environment (Linux) on the same Python version (3.8).

Expected Behavior

I would expect this line to no-op rather than raising. Replacing if hasattr(context, "keylog_filename"): with if hasattr(context, "keylog_filename") and os.environ.get("SSLKEYLOGFILE"): in ssl_.py eliminates the issue.

Actual Behavior

The noted exception is raised.

@sethmlarson
Copy link
Member

Thanks for opening this, this looks like a bug. We'll get a fix in and make a 1.25.11 release.

Would you be willing to provide a patch and test case? If not no problem.

@mattbasta
Copy link
Author

@sethmlarson I'm happy to put up my little patch as a PR. I'm not so sure how to test it, though, since the problem only seems to occur on my one machine running macOS (and I can't possibly be the only person using Stripe's SDK on python 3.8!).

If the fix alone is enough, I can have that up soon. You're welcome to use it as a guide or take it over or whatever.

@mattbasta
Copy link
Author

Awesome, thanks for the fast fix! This is much appreciated.

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 a pull request may close this issue.

2 participants