-
-
Save keum/0d0272d0c98d25654dfd308200f291af 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 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. | |
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 - |
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
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment