Using letsencrypt with Unifi Controller

Submitted by cliff on Wed, 14/03/2018 - 11:23

While using homeassistant in cooperation with the Unifi Controller I regularly see that the homeassist logfiles complains about self-signed certificates. So I wanted to install a legitimate certificate, the obvious choice for a CA would be letsencrypt

After doing some googling I found the following script on reddit. Latest version with edits is available on my github.

apt-get install certbot

cd /usr/local/sbin

wget -O /usr/local/sbin/

chmod +x /usr/local/sbin/

/usr/local/sbin/ -e -d

To automatically update the certificate every 3 months add a file to /etc/cron.d/unifi-cert with the following content:


0 */12 * * * root test -x /usr/local/sbin/ -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && /usr/local/sbin/ -r -d

This cron-job will execute the script. The script it self will update the certificate if it is going to expire within 30 days or less