UniFiController synology letsjpg

Let’s Encrypt certificate on Ubiquiti Unifi Controller installed on Synology Docker

This is a short article describing how to install an SSL Let’s Encrypt certificate on Ubiquiti Unifi Controller that is installed on Synology using Docker.

The article assumes that Docker and Unifi Controller are already installed on your Synology NAS and that the Let’s Encrypt certificate is already added in Synology’s Control Panel. Also that the certificate to be used is the one set as default, although this can be easily modified in the script.

Install Java8 because the terminal commands used for generating and importing the certificate in Unifi Controller’s keystore are part of that package.

java8

Navigate to Task Scheduler and create a scheduled task with root privilege to run once a day that will check if the certificate has been updated within the last 24 hours and then import it in the keystore.

task scheduler
task

Copy and Paste below code in Run Command textbox.

#!/bin/bash
#Should be scheduled to run once a day

echo "Go to the default certificate folder"
sudo su
cd /usr/syno/etc/certificate/_archive/`cat /usr/syno/etc/certificate/_archive/DEFAULT`

#Check if the certificate has been updated within the last 24 hours
if [ $(find . -mtime -1 -type f -name cert.pem) ];then
	echo "Creating certificate"
	openssl pkcs12 -export -inkey privkey.pem -in fullchain.pem -out fullchain.p12 -name unifi -password pass:unifi
	
	echo "Importing certificate"
	keytool -importkeystore -deststorepass aircontrolenterprise -destkeypass aircontrolenterprise -destkeystore /volume1/docker/Unifi-Controller/data/keystore -srckeystore fullchain.p12 -srcstoretype PKCS12 -srcstorepass unifi -alias unifi -noprompt
	
	rm -f fullchain.p12
	
	echo "Restarting Unifi-Controller"
	docker restart Unifi-Controller
else
	echo "Certificate not updated recently"
fi

Now all you have to do is wait for the script to run and do its magic!

Similar Posts

  • Proxy Server

    Build a proxy server in C using threads and sockets. Every server can have up to two connections on the proxy. Client requests must be satisfied. New servers must be added to a list/array upon a request and must be removed if no request comes within 10 seconds. [Source]

  • Crack WEP using KisMAC

    Things you need: An Intel based macbook (other may work) Time! First thing you need to do is to download and install KisMAC. You can do this from http://kismac-ng.org/. Then launch the program and open Preferences. Go to Driver tab, select Apple Airport Extreme card, passive mode and click Add. Then Select All channels and…

  • Packet Sniffing with WireShark

    Download and install Wireshark from http://www.wireshark.org/. Launch the application. Go to Capture -> Options. Select the interface for the wireless network card and tick Capture packets in promiscuous mode. Then press Start. MSN conversation hack: Wireshark will start capturing packets that flow around. Among others we notice at the protocol field the MSNMS (Microsoft Network…

  • New Web Design

    Plenty of free time recently and I decided to change my website’s theme to follow the latest web trends. This template is dedicated to photography, giving blogging a secondary role. During the porting of old posts to this new design, some links and pictures got broken. If you are here to view or download any…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.