Last active
January 27, 2020 18:27
-
-
Save joekir/f014ed2c3e6c3e8a10a8e6cba17f8435 to your computer and use it in GitHub Desktop.
Super Simple local HTTPS Server
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 | |
set -eu | |
CERTNAME=cert.pem | |
KEYNAME=key.pem | |
COMBINED=certs_and_key.pem | |
openssl req -x509 -newkey rsa:1024 -keyout ${KEYNAME} -out ${CERTNAME} -days 365 -subj '/CN=localhost' -passout pass:foobar | |
openssl rsa -in ${KEYNAME} -out ${KEYNAME} -passin pass:foobar | |
cat ${KEYNAME} > ${COMBINED} | |
cat ${CERTNAME} >> ${COMBINED} |
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
from http.server import HTTPServer, SimpleHTTPRequestHandler | |
import ssl | |
httpd = HTTPServer(('localhost', 8443), SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket (httpd.socket, | |
keyfile="key.pem", | |
certfile='cert.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