Forked from rozifus/Python SimpleHTTPServer with SSL
Last active
September 30, 2017 23:06
-
-
Save jorovipe97/3275c51cc5b6a276a2e994df59b24533 to your computer and use it in GitHub Desktop.
Python 3.x https server with SSL
This file contains 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
#!/bin/bash | |
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes |
This file contains 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
import http.server, ssl | |
server_address = ('localhost', 4443) | |
httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket(httpd.socket, | |
server_side=True, | |
certfile='./server.pem', | |
ssl_version=ssl.PROTOCOL_TLSv1) | |
httpd.serve_forever() |
This file contains 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
# 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