Re: Nginx vs Twisted Web

Carl D'Halluin <[email protected]> Tue, 7 Oct 2014 22:21:13 +0000 (UTC)
Newsgroups gmane.comp.python.twisted.web
Message-ID <[email protected]>
> Another problem is that Twisted doesn't yet support SSL on adopted sockets.

I did this by hand:

# Suppose your create/bind/list your listen_socket, and
# its file descriptor is listen_socket_fd


site = server.Site(MyHttpsSite())

cert = '/path/to/my/cert'
key = '/path/to/my/key'

ctx = DefaultOpenSSLContextFactory(key, cert)
tlsFactory = tls.TLSMemoryBIOFactory(ctx, False, site)
p = tcp.Port._fromListeningDescriptor(reactor,
                                             listen_socket_fd,
                                             socket.AF_INET,
                                             tlsFactory)
p._type = 'TLS'
p.startListening()

os.close(listen_socket_fd)
reactor.run()