Skip to content

Commit

Permalink
Always suppress TLS error: [Errno 0] Error
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz authored Apr 25, 2019
2 parents 378f099 + 495c6be commit 2af3b17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ v6.5.5
- :issue:`99` via :pr:`186': Sockets now collect statistics (bytes
read and written) on Python 3 same as Python 2.
- :cp-issue:`1618` via :pr:`180`: Ignore OpenSSL's 1.1+ Error 0
under any Python while wrapping a socket.

v6.5.4
======

Expand Down Expand Up @@ -90,7 +93,7 @@ v6.3.2
v6.3.1
======

- :cp-issue:`1618`: Ignore OpenSSL's 1.0+ Error 0 under Python 2 while
- :cp-issue:`1618`: Ignore OpenSSL's 1.1+ Error 0 under Python 2 while
wrapping a socket.

v6.3.0
Expand Down
11 changes: 2 additions & 9 deletions cheroot/ssl/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type

import sys

try:
import ssl
except ImportError:
Expand Down Expand Up @@ -40,9 +38,6 @@
del socket


IS_BELOW_PY37 = sys.version_info[:2] < (3, 7)


def _assert_ssl_exc_contains(exc, *msgs):
"""Check whether SSL exception contains either of messages provided."""
if len(msgs) < 1:
Expand Down Expand Up @@ -153,8 +148,7 @@ def wrap(self, sock):
except generic_socket_error as exc:
"""It is unclear why exactly this happens.
It's reproducible only under Python<=3.6 with openssl>1.0
and stdlib ``ssl`` wrapper.
It's reproducible only with openssl>1.0 and stdlib ``ssl`` wrapper.
In CherryPy it's triggered by Checker plugin, which connects
to the app listening to the socket port in TLS mode via plain
HTTP during startup (from the same process).
Expand All @@ -163,9 +157,8 @@ def wrap(self, sock):
Ref: https://github.com/cherrypy/cherrypy/issues/1618
"""
is_error0 = exc.args == (0, 'Error')
ssl_doesnt_handle_error0 = IS_ABOVE_OPENSSL10 and IS_BELOW_PY37

if is_error0 and ssl_doesnt_handle_error0:
if is_error0 and IS_ABOVE_OPENSSL10:
return EMPTY_RESULT
raise
return s, self.get_environ(s)
Expand Down

0 comments on commit 2af3b17

Please sign in to comment.