2013-12-17 281 views
2

我有一個關於龍捲風SSL配置的問題。我想處理HTTPS協議。我也閱讀文檔和stackoverflow相同的問題。我有一個SSL證書&關鍵文件。代碼看起來像Tornado SSL證書

settings = dict(
    ... 
    ssl_options = { 
     "certfile": os.path.join("certs/myserver.crt"), 
     "keyfile": os.path.join("certs/myserver.key"), 
    }, 
    ... 
) 
def main(): 
    http_server = tornado.httpserver.HTTPServer(tornado.web.Application(handlers, 
        **settings)) 

    http_server.listen(443) 
    tornado.ioloop.IOLoop.instance().start() 

我啓動我的應用程序後。我想從瀏覽器https://mydomain.com訪問,但它不工作,沒有發生任何事情,它給出了不成功的請求錯誤。我該怎麼辦? BTW http://mydomain.com:443正在工作。

回答

7

你是路過的設置tornado.web.Application()代替tornado.httpserver.HTTPServer

試試這個,

settings = dict(
    ... 
    ssl_options = { 
     "certfile": os.path.join("certs/myserver.crt"), 
     "keyfile": os.path.join("certs/myserver.key"), 
    }, 
    ... 
) 
def main(): 
    http_server = tornado.httpserver.HTTPServer(tornado.web.Application(handlers), 
        ssl_options = { 
    "certfile": os.path.join("certs/myserver.crt"), 
    "keyfile": os.path.join("certs/myserver.key"), 
}) 

    http_server.listen(443) 
    tornado.ioloop.IOLoop.instance().start() 

更新:

settings = dict(
    ... 
    ssl_options = { 
     "certfile": os.path.join("certs/myserver.crt"), 
     "keyfile": os.path.join("certs/myserver.key"), 
    }, 
    ... 
) 
def main(): 
    http_server = tornado.httpserver.HTTPServer(tornado.web.Application(handlers), **settings) 

    http_server.listen(443) 
    tornado.ioloop.IOLoop.instance().start() 
+1

Praveen感謝您的回答,但其他設置如何? – zi0408

+0

我已經更新了答案...嘗試.. – Praveen

+0

在設置字典中有例如template_path的關鍵參數。現在龍捲風給TypeError:__init __()得到了一個意外的關鍵字參數'template_path'error – zi0408