Skip to content

Instantly share code, notes, and snippets.

@jbelke
Forked from stephenlb/https.py
Created December 31, 2015 07:55
Show Gist options
  • Save jbelke/9c9902f26f877f10ac00 to your computer and use it in GitHub Desktop.
Save jbelke/9c9902f26f877f10ac00 to your computer and use it in GitHub Desktop.
HTTPS Server - All-in-One Secure HTTPS Server
#!/usr/bin/python
# server
# python https.py
#
# browser
# https://0.0.0.0:4443
import BaseHTTPServer
import SimpleHTTPServer
import ssl
import os
os.system("openssl req -new -keyout server.pem -out server.pem -x509 -days 365 -nodes -subj '/CN=www.pubnub.com/O=PubNub/C=US'")
httpd = BaseHTTPServer.HTTPServer( ( '0.0.0.0', 4443 ), SimpleHTTPServer.SimpleHTTPRequestHandler )
httpd.socket = ssl.wrap_socket( httpd.socket, certfile='./server.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