Skip to content

Instantly share code, notes, and snippets.

@h007
Forked from 0xBADCA7/ssl_server.py
Last active January 11, 2022 09:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h007/196575c0d68d3832d246f1a32c07e6fd to your computer and use it in GitHub Desktop.
Save h007/196575c0d68d3832d246f1a32c07e6fd to your computer and use it in GitHub Desktop.
Simple HTTPS server in Python 3
#!/usr/bin/env python3
from http.server import HTTPServer,SimpleHTTPRequestHandler
from socketserver import BaseServer
import ssl
httpd = HTTPServer(('0.0.0.0', 1443), SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='certificate.pem', keyfile='privatekey.pem', server_side=True)
httpd.serve_forever()
@dncpax
Copy link

dncpax commented Dec 8, 2021

to create the cert without installing anything:

openssl genrsa > privatekey.pem
openssl req -new -x509 -key privatekey.pem -out certificate.pem -days 365

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