Skip to content

Instantly share code, notes, and snippets.

@stephenbradshaw
Created November 5, 2020 01:26
  • Star 27 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Python 3 Simple HTTPS server
#!/usr/bin/env python3
# python3 update of https://gist.github.com/dergachev/7028596
# Create a basic certificate using openssl:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# Or to set CN, SAN and/or create a cert signed by your own root CA: https://thegreycorner.com/pentesting_stuff/writeups/selfsignedcert.html
import http.server
import ssl
httpd = http.server.HTTPServer(('127.0.0.1', 443), http.server.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./server.pem', server_side=True)
httpd.serve_forever()
@danperrout
Copy link

Awesome!

If you want to expose it to the world, just change '127.0.0.1' to '0.0.0.0'

@NadgobKhan
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment