[Twisted-web] Nginx vs Twisted Web

Carl D'Halluin carl at amplidata.com
Tue Oct 7 16:21:13 MDT 2014


> 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()




More information about the Twisted-web mailing list