Skip to content

Instantly share code, notes, and snippets.

@marcelosantos
Last active February 12, 2017 03:04
Show Gist options
  • Save marcelosantos/35d2eb9f6f32dfeaaac3d9eaa087de09 to your computer and use it in GitHub Desktop.
Save marcelosantos/35d2eb9f6f32dfeaaac3d9eaa087de09 to your computer and use it in GitHub Desktop.

Heroku and Let's Encrypt Certs

Install certbot

brew install certbot

Generate Certs manualy

sudo certbot certonly --manual

Terminal show you the below message

Make sure your web server displays the following content at
http://www.EXAMPLE.com/.well-known/acme-challenge/xxxxxxxxxxxx-yyyy.zzzzzzzzzzzzzzzzzzz before continuing:
xxxxxxxxxxxx-yyyy.zzzzzzzzzzzzzzzzzzz
If you don’t have HTTP server configured, you can run the following
command on the target server (as root):
mkdir -p /tmp/certbot/public_html/.well-known/acme-challenge
cd /tmp/certbot/public_html
printf “%s” Gm35kFLiXnNtKT9OAOG_KPZvqMmYYAZU6DN-QRoGclg.s2I4ZV9Ne2CNtczlqXV9uw1ZdB5OSypG_cIdiuT7BwI > .well-known/acme-challenge/Gm35kFLiXnNtKT9OAOG_KPZvqMmYYAZU6DN-QRoGclg
# run only once per server:
$(command -v python2 || command -v python2.7 || command -v python2.6) -c \
“import BaseHTTPServer, SimpleHTTPServer; \
s = BaseHTTPServer.HTTPServer((‘’, 80), SimpleHTTPServer.SimpleHTTPRequestHandler); \
s.serve_forever()”
Press ENTER to continue

Add to you webserver a URL action for domain verification and so enable let's encrypt owner

Domain verification with NodeJS/Express GET route

app.get('/.well-known/acme-challenge/:content', function(req, res) {
  res.send('xxxxxxxxxxxx-yyyy.zzzzzzzzzzzzzzzzzzz')
})

After deploy the before code to serve, press ENTER

If successful, it will show you a congratulation message and tell you the location of the certificate. Yeh then it is time to upload the certificate to heroku!

Add Let's Encrypt Certs on Heroku Server

heroku certs:add /etc/letsencrypt/live/www.example.com/fullchain.pem /etc/letsencrypt/live/www.example.com/privkey.pem

Based on https://medium.com/@franxyzxyz/setting-up-free-https-with-heroku-ssl-and-lets-encrypt-80cf6eac108e#.vjapv7irt

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