Skip to content

Instantly share code, notes, and snippets.

@allyjweir
Forked from claudiosanches/django-runserver-ssl.md
Last active August 13, 2018 10:30
Show Gist options
  • Save allyjweir/e48c2792f584124261a3b278312be4b8 to your computer and use it in GitHub Desktop.
Save allyjweir/e48c2792f584124261a3b278312be4b8 to your computer and use it in GitHub Desktop.
Django - SSL with runserver

Instalation

[sudo] apt-get install stunnel

Configuration

cd path/to/django/project
mkdir stunnel
cd stunnel

Create the key:

openssl genrsa 1024 > stunnel.key
openssl req -new -x509 -nodes -sha1 -days 365 -key stunnel.key > stunnel.cert
cat stunnel.key stunnel.cert > stunnel.pem

Create the dev_https file with:

pid=

cert = stunnel/stunnel.pem
foreground = yes
output = stunnel.log

[https]
accept=0.0.0.0:8443
connect=0.0.0.0:8000
TIMEOUTclose=1

In one terminal run:

stunnel stunnel/dev_https

In another, run:

./runserver

Sets the permission:

chmod a+x runserver

The SSL works in:

https://localhost:8443 
REF

http://stackoverflow.com/questions/8023126/how-can-i-test-https-connections-with-django-as-easily-as-i-can-non-https-connec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment