-
-
Save RichardBronosky/644cdfea681518403f5409fa16823c1f to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/ | |
# generate server.xml with the following command: | |
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes | |
# run as follows: | |
# python simple-https-server.py | |
# then in your browser, visit: | |
# https://localhost:4443 | |
import http.server | |
import ssl | |
httpd = http.server.HTTPServer(('0.0.0.0', 443), http.server.SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket(httpd.socket, certfile='./fullchain.pem', keyfile='./privkey.pem', server_side=True, ssl_version=ssl.PROTOCOL_TLSv1_2) | |
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
#!/usr/bin/env python2 | |
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/ | |
# generate certificates with the following command: | |
# export [email protected] | |
# export DOMAIN=example.com | |
# curl -sL https://gist.githubusercontent.com/RichardBronosky/644cdfea681518403f5409fa16823c1f/raw/get_letsencrypt_cert.sh | bash | |
# create symbloic links to the certificates | |
# ln -s /etc/letsencrypt/live/$DOMAIN/fullchain.pem ./ | |
# ln -s /etc/letsencrypt/live/$DOMAIN/privkey.pem ./ | |
# run as follows: | |
# python simple-https-server.py | |
# then in your browser, visit: | |
# https://localhost or https://$DOMAIN | |
import BaseHTTPServer, SimpleHTTPServer | |
import ssl | |
httpd = BaseHTTPServer.HTTPServer(('0.0.0.0', 443), SimpleHTTPServer.SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket(httpd.socket, certfile='./fullchain.pem', keyfile='./privkey.pem', server_side=True, ssl_version=ssl.PROTOCOL_TLSv1_2) | |
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
#!/usr/bin/env bash | |
# This script uses the concept at https://certbot.eff.org/#ubuntuxenial-other | |
# but overcomes the problem I consistently have of the server (at eff.org) | |
# not being able to connect to this machine. Given x_ prefix to correct github sorting. | |
mkdir -p /tmp/www | |
cd /tmp/www | |
sudo python -m SimpleHTTPServer 80 & | |
http_pid=$! | |
sudo certbot certonly \ | |
--agree-tos \ | |
--webroot \ | |
--webroot-path $PWD \ | |
--email $EMAIL \ | |
--domain $DOMAIN | |
sudo kill --signal SIGINT $http_pid | |
cd - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment