How to: Development Server with SSL Enabled using Python3

Simple HTTPS Server using Python

Nishān Wickramarathna
2 min readSep 27, 2019

This is a very short description on how to create a development server using python.

First you need OpenSSL (if you are on Linux, OpenSSL should be automatically installed), on windows, go to http://downloads.sourceforge.net/gnuwin32/openssl-0.9.8h-1-setup.exe and install the setup.

Also on Windows, go to https://indy.fulgan.com/SSL/openssl-1.0.2t-x64_86-win64.zip, and unzip.

Then open up cmd in this folder and type this command. (on Windows)

set OPENSSL_CONF=C:\Program Files (x86)\GnuWin32\share\openssl.cnf

Afterwards on both Windows and Linux, type this command and hit enter. (This is the only command you need in Linux, but you need to do previous steps in Windows.)

openssl req -new -x509 -keyout key.pem -out server.pem -days 365 -nodes

Follow the steps and create key.pem and server.pem

Copy created key.pem and server.pem to the foder you want your server to start.

Create server.py in the same directory and copy following code.

Open terminal (or cmd) in the same folder and type,

python server.py //On windows
sudo python3 server.py //On Linux

On Linux, usually default python version is 2.x so you might need to install python 3.x, hence python3 server.py

Then navigate to https://localhost:4443

That’s it. Please comment if any on the links do not work or if you have questions.

--

--

No responses yet