Skip to content

Instantly share code, notes, and snippets.

@dlangille
Created January 23, 2017 20:27
Show Gist options
  • Save dlangille/8447e735c0ca15cdbfd8cef01842b36e to your computer and use it in GitHub Desktop.
Save dlangille/8447e735c0ca15cdbfd8cef01842b36e to your computer and use it in GitHub Desktop.
Importing your own cert into a Unifi controller
# All of this was run on FreeBSD 11, but with path adjustments to the keystore, should work for any OS.
# Your cert is in your local directory:
#
# unifi01.int.unixathome.org.key
# unifi01.int.unixathome.org.pem
# aircontrolenterprise is the password we are using on our pkcs12 file
# crete the keys.p12 file
# the -name directive specifies the alias for this cert.
# aliases appear in the list command below
echo aircontrolenterprise | openssl pkcs12 -export -inkey unifi01.int.unixathome.org.key \
-in unifi01.int.unixathome.org.pem -name unifi01 \
-out keys.p12 \
-password stdin
# import keys.p12 into the keystore
sudo keytool -importkeystore -srckeystore keys.p12 \
-srcstoretype pkcs12 -destkeystore /usr/local/share/java/unifi/data/keystore \
-storepass aircontrolenterprise -srcstorepass aircontrolenterprise
# list the certs in the keystore
# this is where we see the aliases
keytool -list -keystore /usr/local/share/java/unifi/data/keystore
# delete the one we don't want: we imported unifi01 alias above.
# the unifi alias was created by the controller by default
sudo keytool -delete -keystore /usr/local/share/java/unifi/data/keystore -alias unifi
# restart the controller
sudo service unifi restart
@dlangille
Copy link
Author

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