diff --git a/cheroot/ssl/builtin.py b/cheroot/ssl/builtin.py index 2501f2e3db..871d1d545b 100644 --- a/cheroot/ssl/builtin.py +++ b/cheroot/ssl/builtin.py @@ -272,20 +272,21 @@ def bind(self, sock): def wrap(self, sock): """Wrap and return the given socket, plus WSGI environ entries.""" + EMPTY_RESULT = None, {} try: s = self.context.wrap_socket( sock, do_handshake_on_connect=True, server_side=True, ) - return s, self.get_environ(s) except ssl.SSLError as ex: if ex.errno == ssl.SSL_ERROR_SSL: if _assert_ssl_exc_contains(ex, 'http request'): # The client is speaking HTTP to an HTTPS server. raise errors.NoSSLError - except (generic_socket_error, ssl.SSLZeroReturnError): + except generic_socket_error: pass - # empty result - return None, {} + else: + return s, self.get_environ(s) + return EMPTY_RESULT def get_environ(self, sock): """Create WSGI environ entries to be merged into each request."""