Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tornado SSL certs

I have a question about tornado SSL configuration. I wanna handle HTTPS protocol. I also read docs and stackoverflow same issues. I have a SSL certificate & key files. Code looks like

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

After I starting my app. I wanna access from browser https://mydomain.com but it is not working and nothing happened it gives unsuccess request error. What should I do? BTW http://mydomain.com:443 is working.

like image 287
Munkhtsogt Avatar asked Sep 08 '25 11:09

Munkhtsogt


1 Answers

You are passing the settings to tornado.web.Application() instead of tornado.httpserver.HTTPServer

Try this,

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

Update:

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()
like image 143
Praveen Avatar answered Sep 10 '25 05:09

Praveen