Monday, September 6, 2021

Installing a Real SSL Certificate on a UniFi Cloud Key

 I recently decided that I was no longer going to tolerate my UniFi Cloud Key's web management tool using a self-signed SSL certificate. I have, many times in the past, replaced the supplied certificates on the self-installed UniFi Controller software that I have run, on various Raspberry Pis or Linux VMs. The process has never been all that cumbersome, and it involved updating the `keystore.jks` file, and restarting the UniFi Controller.

However, the process seems to be very different, on the Cloud Key Gen 2. I'm not sure if the same goes for the Gen 1 Cloud Key, but it seems likely, as UniFi tends to update the software on all devices, with each release. I'd have no problem with this, but the process is completely undocumented.

After many, many hours of poking and prodding my Cloud Key, and much searching of the UniFi Community forum, I found the following fantastic post, from the user loafbread:

https://community.ui.com/questions/Install-a-Commercial-Wildcard-SSL-Certificate-on-Cloud-Key-and-Controller/040c640e-5c48-4477-82dd-aff56178d3f3#answer/b3bb7541-51d0-432a-a33b-b9864615604d

So, it seems that Ubiquiti has made the SSL certificate process much easier. Fantastic, of course, but they somehow failed to document that fact. To make sure that this critical bit of information is maintained, I will summarize the process, here:

  1. copy your PEM-format certificates to your Cloud Key
    1. you will need both the certificate itself and the full CA chain certificate files
  2. back up the following files:
    1. cp -p /data/unifi-core/config/unifi-core.crt /data/unifi-core/config/unifi-core.crt.orig
    2. cp -p /data/unifi-core/config/unifi-core.key /data/unifi-core/config/unifi-core.key.orig
  3. replace the the unifi-core.crt file with your full CA certificate chain and the unifi-core.key file with your certificate
  4. restart the unifi-core service
    1. systemctl restart unifi-core.service

So, the process isn't difficult, if it were only documented.

Oh well.