Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does cyclone (python) support HTTPS connections and SSL?

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...

like image 783
Abe Avatar asked Mar 17 '12 02:03

Abe


2 Answers

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

like image 128
fiorix Avatar answered Oct 09 '22 19:10

fiorix


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.

like image 30
jfs Avatar answered Oct 09 '22 18:10

jfs