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

Catch urllib3.exceptions.SSLError in Response.iter_content #6056

Closed
anadius opened this issue Feb 4, 2022 · 2 comments
Closed

Catch urllib3.exceptions.SSLError in Response.iter_content #6056

anadius opened this issue Feb 4, 2022 · 2 comments

Comments

@anadius
Copy link

anadius commented Feb 4, 2022

I believe requests should catch that and raise requests.exceptions.SSLError:

Traceback (most recent call last):
  File "urllib3\response.py", line 438, in _error_catcher
  File "urllib3\response.py", line 519, in read
  File "http\client.py", line 465, in read
  File "socket.py", line 705, in readinto
  File "ssl.py", line 1273, in recv_into
  File "ssl.py", line 1129, in read
ssl.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2536)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tkinter\__init__.py", line 1921, in __call__
  File "tkinter\__init__.py", line 839, in callit
  File "updater_gui.py", line 421, in metadata_cached
  File "concurrent\futures\_base.py", line 438, in result
  File "concurrent\futures\_base.py", line 390, in __get_result
  File "concurrent\futures\thread.py", line 58, in run
  File "updater\updater.py", line 314, in get_metadata
  File "pzd.py", line 256, in get_info
  File "pzd.py", line 216, in _get_central_dir
  File "pzd.py", line 176, in _get_chunk
  File "pzd.py", line 170, in _get_range
  File "requests\models.py", line 836, in content
  File "requests\models.py", line 758, in generate
  File "urllib3\response.py", line 576, in stream
  File "urllib3\response.py", line 512, in read
  File "contextlib.py", line 153, in __exit__
  File "urllib3\response.py", line 449, in _error_catcher
urllib3.exceptions.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2536)

This is requests 2.26.0.

That's some edge case and I've seen that happen only once (this is automatic error report from my program so I don't know any details, it's anonymous). I'm not trying to solve the problem, I just want to be able to catch requests.exceptions.SSLError instead of urllib3.exceptions.SSLError.

@anadius anadius changed the title Catch urllib3.exceptions.SSLError in Response.content Catch urllib3.exceptions.SSLError in Response.iter_content Feb 4, 2022
@nateprewitt
Copy link
Member

Thanks for reporting the issue @anadius. We've definitely had a few cases where either new or rarely raised exceptions from urllib3 leak through. I've added #6057 as a proposal to handle this.

@nateprewitt
Copy link
Member

We've merged #6057, so I'd expect this change to be available in the next release.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants