Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thenoobtester/e5073a1bb2a0c2d90da471a71da1427f to your computer and use it in GitHub Desktop.
Save thenoobtester/e5073a1bb2a0c2d90da471a71da1427f to your computer and use it in GitHub Desktop.
Simple SSL Web Server using python's SimpleHTTPServer
# adapated from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate seperate key+crt files, make sure common name (CN) == ip or hostname
# openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout newkey.key -out newkey.crt
# run as follows:
# python simple-https-server.py
import BaseHTTPServer, SimpleHTTPServer
import ssl
# 0.0.0.0 allows connections from anywhere
httpd = BaseHTTPServer.HTTPServer(('0.0.0.0', 443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./newkey.crt', keyfile='./newkey.key', server_side=True)
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment