Created
October 30, 2018 08:28
-
-
Save xopr/cf0c71ff545be93f118504b69c3ac73f to your computer and use it in GitHub Desktop.
ssl test webserver in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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