Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save minkione/32d113cb3efd211480c14a5dd2ed2bc1 to your computer and use it in GitHub Desktop.
Save minkione/32d113cb3efd211480c14a5dd2ed2bc1 to your computer and use it in GitHub Desktop.
Python SimpleHTTPServer with SSL
#!/bin/bash
openssl req -new -x509 -keyout yourpemfile.pem -out yourpemfile.pem -days 365 -nodes
import BaseHTTPServer, SimpleHTTPServer
import ssl
httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, server_side=True,
certfile='yourpemfile.pem')
httpd.serve_forever()
# useful for running ssl server on localhost
# which in turn is useful for working with WebSocket Secure (wss)
# copied from http://www.piware.de/2011/01/creating-an-https-server-in-python/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment