Member-only story

Python, add SSL to a Tornado App + redirect from HTTP to HTTPS

Alessandro
Feb 11, 2021

--

DALL-E: A sleek, modern illustration for a tech article, featuring a stylized python wrapped around a tornado. The python symbolizes the Python programming

A quick way to install SSL certificates is to add the ssl_options to your HTTPServer, using the os.path.join with a relative folder location, and the file name (this works on both Windows and Linux, just keep in mind you need to use the os.path.join function).

The second step is to make sure your RequestHandler redirects to your using HTTPS protocol by doing a redirect on the prepare method as shown below.

The full code for the application is shown below:

Hope this helps!

--

--

Alessandro
Alessandro

Written by Alessandro

Full mobile stack developer, researcher, simulation software developer, and parent.

No responses yet

Write a response