Skip to content

Instantly share code, notes, and snippets.

@xopr
Created October 30, 2018 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xopr/cf0c71ff545be93f118504b69c3ac73f to your computer and use it in GitHub Desktop.
Save xopr/cf0c71ff545be93f118504b69c3ac73f to your computer and use it in GitHub Desktop.
ssl test webserver in python
# Create certificate
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.pem -out mycert.pem -subj "/C=NL/ST=Limburg/L=Heerlen/O=ACKspace/OU=demo/CN=localhost.ackspace.nl"
# Copied from https://www.piware.de/2011/01/creating-an-https-server-in-python/
import BaseHTTPServer, SimpleHTTPServer
import ssl
# add localhost to limit interfaces
httpd = BaseHTTPServer.HTTPServer(('', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket( httpd.socket, certfile='mycert.pem', server_side=True )
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment