Requirements
- Unifi Controller running on Linux
- Windows Certificate Authority
- Keystore Explorer
- SSH Client
- WinSCP
Windows CA
Certificate Template
Run certtmpl.msc to open certificate template management console
I am using customized template with the following settings:
- General
- Name: Custom Application
- Template Name: CustomApplication
- Validity: 2 years. This number is configurable
- Renewal period: 6 weeks
- Do NOT publish certificate in Active Directory
- Compatibility
- CA: 2008R2
- Recipient: XP/2003
- Request Handling
- Purpose: Signature and Encryption
- Allow private key to be exported
- Cryptography
- Algo: Determined by CSP
- Min key size: 2048
- Crypto provider: One of the following providers:
- MS RSA SChannel
- MS DH SChannel
- Extension:
- Application Policies
- Basic Constraints
- Certificate Template Information
- Issuance Policies
- Key Usage
- Digital Signature
- Signature is proof of origin
- Allow key exchange only with key encryption
- Make this extension critical
- Security
- As required
Request Certificate
Credit: Installing a custom SSL certificate on a UniFi Controller – Blinky’s Blog (cracknells.co.uk)
- Open
Manage Computer Certificatemanagement console - In Personal > Certificate, make a request to abovementioned template
- Fill in with the following:
- CN=unifi.example.org
- OU=Dept
- O=ExampleCompany
- L=Town
- S=State
- C=SG
- DNS
- unifi.example.org
- 172.16.0.2
- IP (v4) = 172.16.0.2
- Once requested, Export the new certificate:
- With private key
- .PFX
- Include all certificates in the certification path if possible
- Encryption:
TripeDES-SHA1 - Set password as
aircontrolenterprise
- From this point onwards, this cert will be called
unifi_new_cert.pfx
Unifi Controller
Credit: Ubiquiti Unifi Controller SSL Certificate creation process – Tielen Consultancy (jeroentielen.nl)
Getting keystore file
- SSH into server ( in this case, we are using user1 )
- Login with su (root)
- Run the commands below
- Afterwards, copy this file using WinSCP
# Change to data folder
cd /usr/lib/unifi/data
# Make a backup copy
cp keystore keystore.bak
# Copy to home directory
cp keystore ~/keystore
# Change owner
chown user1:user1 ~/keystore
Opening keystore file
- On Windows machine, use KeyStore Explorer
- Open keystore file copied from section above
- Delete the existing key pair
- Click on Tools > Import key pair > PKCS12
- Locate the
unifi_new_cert.pfx - Enter password from section above (
aircontrolenterprise) - Key pair alias must be
unifi - Provide a new password (
aircontrolenterprise) - Save the keystore file
Upload keystore file
- Using WinSCP, copy the file back to server
- Run the following command (with root)
# change owner
chown unifi:unifi ~/keystore
# copy file
cp ~/keystore /usr/lib/unifi/data/keystore
reboot