Skip to content

Instantly share code, notes, and snippets.

@ravnoor
Created April 6, 2018 00:38
Show Gist options
  • Save ravnoor/4a9249ba4f9fbe096c4d88f11ca32c5f to your computer and use it in GitHub Desktop.
Save ravnoor/4a9249ba4f9fbe096c4d88f11ca32c5f to your computer and use it in GitHub Desktop.
#!/bin/bash
mkdir -p /tmp/certbot/public_html/
cd /tmp/certbot/public_html
# forward external port 80 to internal port [unifi-controller-ip]:9000
python -m SimpleHTTPServer 9000
sudo cp -r /etc/letsencrypt/live/unifi.domain.com/ ~/Desktop/certbot/
# renew certificate
# sudo certbot renew --webroot -w /tmp/certbot/public_html
cd ~/Desktop/certbot/
# convert PEM to PKCS12 format
openssl pkcs12 -export -in ~/Desktop/certbot/cert.pem -inkey privkey.pem -certfile chain.pem -out unifi.p12 -name unifi -password pass:aircontrolenterprise
# import SSL certificate to the unifi keystore, requires Java SDK [http://www.oracle.com/technetwork/java/javase/downloads/index.html]
keytool -importkeystore -srckeystore unifi.p12 -srcstoretype PKCS12 -srcstorepass aircontrolenterprise -destkeystore /Applications/Unifi.app/Contents/Resources/data/keystore -storepass aircontrolenterprise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment