Commit 975d1c0b authored by Vincent Pelletier's avatar Vincent Pelletier

http: Do not start listening on https port before wrapping socket.

Otherwise, this port will fail https handshake if clients connects too
early.
parent 50a5d1d3
...@@ -86,6 +86,14 @@ class ThreadingWSGIServer(ThreadingMixIn, WSGIServer): ...@@ -86,6 +86,14 @@ class ThreadingWSGIServer(ThreadingMixIn, WSGIServer):
self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1) self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
WSGIServer.server_bind(self) WSGIServer.server_bind(self)
class ThreadingWSGISSLServer(ThreadingWSGIServer):
"""
Threading WSGI SSL server
Delay socket opening to leave time for socket wrapping.
"""
def __init__(self, *args, **kw):
ThreadingWSGIServer.__init__(self, bind_and_activate=False, *args, **kw)
class CaucaseWSGIRequestHandler(WSGIRequestHandler): class CaucaseWSGIRequestHandler(WSGIRequestHandler):
""" """
Make WSGIRequestHandler logging more apache-like. Make WSGIRequestHandler logging more apache-like.
...@@ -501,7 +509,7 @@ def main(argv=None, until=utils.until): ...@@ -501,7 +509,7 @@ def main(argv=None, until=utils.until):
host=host, host=host,
port=https_port, port=https_port,
app=application, app=application,
server_class=ThreadingWSGIServer, server_class=ThreadingWSGISSLServer,
handler_class=CaucaseSSLWSGIRequestHandler, handler_class=CaucaseSSLWSGIRequestHandler,
), ),
) )
...@@ -519,6 +527,12 @@ def main(argv=None, until=utils.until): ...@@ -519,6 +527,12 @@ def main(argv=None, until=utils.until):
sock=https.socket, sock=https.socket,
server_side=True, server_side=True,
) )
try:
https.server_bind()
https.server_activate()
except:
https.server_close()
raise
if args.backup_directory: if args.backup_directory:
backup_period = datetime.timedelta(args.backup_period, 0) backup_period = datetime.timedelta(args.backup_period, 0)
try: try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment