From Newroco tech docs
Jump to: navigation, search

Certbot sets up a free Lets Encrypt certificate for your website. The following instructions are for Certbot which is the tool supplied by the EFF (the creators of Lets Encrypt) to help with setup. These notes are for a simple single site with defaults.

Ensure your server has a DNS record exists for the domain name(s) you will be using.

NB LetsEncrypt do not support wildcard certificates, but given it's no additional cost (and easy) to generate certs for different domains, or a cert will multiple domain names attached, wildcards are not a big issue.

Retrieve the certbot-auto script, make it executable, copy it somewhere in the default path and execute it:

  2. apt-get -y install python-pip
  3. wget https://dl.eff.org/certbot-auto
  4. chmod a+x certbot-auto
  5. cp certbot-auto /usr/bin/
  2. #Create an certificate for all domains
  3. certbot-auto --apache
  4. #Create an certificate for a specific domain
  5. certbot-auto --apache --cert-name example.com -d 1.example.com,2.example.com

Follow the prompts displayed, making sure you enter the domain name(s) correctly. Given the current environment when asked about whether you want to have HTTP available it's recommended to take the "secure" option (HTTPS only).

If the certificate generates successfully, next configure auto-renew. Test this first by running

  1. certbot-auto renew --dry-run

and if successful add auto-renew to cron.daily

  1. sudo vim /etc/cron.daily/autorenew
  3. #!/bin/sh
  4. ##script to run Lets Encrypt certificate renewal check/update tool
  5. certbot-auto renew --quiet --no-self-upgrade

and make it executable

  1. sudo chmod +x /etc/cron.daily/autorenew

You should occasionally run certbot-auto manually to let it upgrade, but the auto command will keep certificates updated in between.

Revoking a certificate

  1. certbot-auto revoke --cert-path /etc/letsencrypt/live/<cert-name>/cert.pem

Ubuntu 16.04

Certbot is packaged for 16.04, so apt-get the following package:

  1. $ sudo apt-get install python-letsencrypt-apache

It also has an Apache plugin that automates obtaining and installing certificates:

  1. letsencrypt --apache

You can also add domains manually, useful for adding aliases to a single certificate e.g. example.com & www.example.com

  1. letsencrypt --apache --domains example.com,www.example.com
  1. letsencrypt renew --dry-run --agree-tos


There's a bug in the version of Certbot on Ubuntu Xenial which may show a warning saying 'Registering without email!' even if you have previously given an email to Certbot. Don't worry if this happens, it will not effect your renewal. If that appears to be working correctly, you can arrange for automatic renewal by adding a cron or systemd job which runs the following:

  1. letsencrypt renew

Errors might appear


  2. Traceback (most recent call last):
  3. File "/usr/lib/python3/dist-packages/virtualenv.py", line 2363, in <module>
  4. main()
  5. File "/usr/lib/python3/dist-packages/virtualenv.py", line 719, in main
  6. symlink=options.symlink)
  7. File "/usr/lib/python3/dist-packages/virtualenv.py", line 988, in create_environment
  8. download=download,
  9. File "/usr/lib/python3/dist-packages/virtualenv.py", line 918, in install_wheel
  10. call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  11. File "/usr/lib/python3/dist-packages/virtualenv.py", line 812, in call_subprocess
  12.  % (cmd_desc, proc.returncode))
  13. OSError: Command /opt/eff.org/certbot/venv/bin/python2.7 - setuptools pkg_resources pip wheel failed with error code 1


  2. export LC_ALL=C