ssl.SSLError during handshake can teardown worker process (#111)
prevent socket which is listening been close when TcpConnectionUninitializedException is raised
This commit is contained in:
parent
22079c3dbb
commit
542cd42733
22
proxy.py
22
proxy.py
|
@ -396,12 +396,23 @@ class Worker(multiprocessing.Process):
|
||||||
except BlockingIOError: # as e:
|
except BlockingIOError: # as e:
|
||||||
# logger.exception('BlockingIOError', exc_info=e)
|
# logger.exception('BlockingIOError', exc_info=e)
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
work = self.work_klass(
|
work = self.work_klass(
|
||||||
fileno=conn.fileno(),
|
fileno=conn.fileno(),
|
||||||
addr=addr,
|
addr=addr,
|
||||||
**self.kwargs)
|
**self.kwargs)
|
||||||
work.setDaemon(True)
|
work.setDaemon(True)
|
||||||
work.start()
|
work.start()
|
||||||
|
except ssl.SSLError as e:
|
||||||
|
logger.exception('ssl.SSLError', exc_info=e)
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception('Error encountered', exc_info=e)
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
conn.shutdown(socket.SHUT_RDWR)
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception('Error trying to shutdown client socket', exc_info=e)
|
||||||
|
conn.close()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
@ -1540,7 +1551,6 @@ class ProtocolHandler(threading.Thread):
|
||||||
Shutdown and closes client connection upon error.
|
Shutdown and closes client connection upon error.
|
||||||
"""
|
"""
|
||||||
if self.config.certfile and self.config.keyfile:
|
if self.config.certfile and self.config.keyfile:
|
||||||
try:
|
|
||||||
ctx = ssl.create_default_context(
|
ctx = ssl.create_default_context(
|
||||||
ssl.Purpose.CLIENT_AUTH)
|
ssl.Purpose.CLIENT_AUTH)
|
||||||
ctx.options |= ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
|
ctx.options |= ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
|
||||||
|
@ -1550,16 +1560,6 @@ class ProtocolHandler(threading.Thread):
|
||||||
keyfile=self.config.keyfile)
|
keyfile=self.config.keyfile)
|
||||||
conn = ctx.wrap_socket(conn, server_side=True)
|
conn = ctx.wrap_socket(conn, server_side=True)
|
||||||
return conn
|
return conn
|
||||||
except Exception as e:
|
|
||||||
logger.exception('Error encountered', exc_info=e)
|
|
||||||
try:
|
|
||||||
conn.shutdown(socket.SHUT_RDWR)
|
|
||||||
except Exception as e:
|
|
||||||
logger.exception('Error trying to shutdown client socket', exc_info=e)
|
|
||||||
finally:
|
|
||||||
conn.close()
|
|
||||||
return None
|
|
||||||
return conn
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def now() -> datetime.datetime:
|
def now() -> datetime.datetime:
|
||||||
|
|
Loading…
Reference in New Issue