Ubuntu instructions (https://certbot.eff.org/lets-encrypt/ubuntutrusty-other) summary:
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install certbot
sudo certbot certonly
Use the temporary server version.
NOTE: In EC2 security groups make sure to add HTTPS (port 443) open on inbound. You should already have port 80 open.
from flask import Flask
import ssl
app = Flask(__name__)
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain(
# Use your own domain name of course
certfile = '/etc/letsencrypt/live/blog.self-loop.com/cert.pem',
keyfile = '/etc/letsencrypt/live/blog.self-loop.com/privkey.pem',
)
@app.route("/")
def hello():
return "Hello World!"
app.run(
# Get your own hostname by typing `hostname` in the command line.
host = 'ip-172-31-4-252',
# You probably need to set the port explicitly.
port = 443,
ssl_context = context
)