Question

Does cyclone (python) support HTTPS connections and SSL? If so, can you please provide an example?

I've looked through the documentation and code on the cyclone github page, and can't find any reference to SSL. But since lots of cyclone is just wrapping twisted, maybe there's something I'm missing...

Was it helpful?

Solution

From the README:

cyclone is a Twisted protocol, therefore it may be used in conjunction with any other protocol implemented in Twisted.

If Twisted supports SSL then cyclone supports it e.g.:

#file: cyclone-ssl.py
import cyclone.web

class IndexHandler(cyclone.web.RequestHandler):
    def get(self):
        self.write("hello world")

factory = cyclone.web.Application([(r"/", IndexHandler)])
portstr = "ssl:4443:privateKey=server_key.pem:certKey=server_cert.pem"

# make twisted app
from twisted.application import service, strports

application = service.Application("cyclone-ssl")
strports.service(portstr, factory).setServiceParent(application)

Run it as:

$ twistd -ny cyclone-ssl.py

The part that activates ssl is portstr. It specifies that the server serves on 4443 port and uses server_key.pem as its private key, server_cert.pem as a certificate.

OTHER TIPS

SSL examples have been added after I found this post. It's here: https://github.com/fiorix/cyclone/tree/master/demos/ssl

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top