【发布时间】:2012-03-17 02:23:44
【问题描述】:
cyclone (python) 是否支持 HTTPS 连接和 SSL?如果有,能否举个例子?
我查看了cyclone github page 上的文档和代码,但找不到任何对 SSL 的引用。但是由于很多旋风只是缠绕扭曲,也许我缺少一些东西......
【问题讨论】:
cyclone (python) 是否支持 HTTPS 连接和 SSL?如果有,能否举个例子?
我查看了cyclone github page 上的文档和代码,但找不到任何对 SSL 的引用。但是由于很多旋风只是缠绕扭曲,也许我缺少一些东西......
【问题讨论】:
在我找到这篇文章后添加了 SSL 示例。在这里:https://github.com/fiorix/cyclone/tree/master/demos/ssl
【讨论】:
来自README:
cyclone 是一个 Twisted 协议,因此它可以结合使用 与 Twisted 中实现的任何其他协议。
如果 Twisted 支持 SSL,则 cyclone 支持它,例如:
#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)
运行如下:
$ twistd -ny cyclone-ssl.py
激活ssl的部分是portstr。它指定服务器在4443 端口上服务,并使用server_key.pem 作为其私钥,server_cert.pem 作为证书。
【讨论】: