Skip to content

Instantly share code, notes, and snippets.

@synthead
Created December 8, 2017 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save synthead/4b464751fa363df4ebe5a58a5e6cef94 to your computer and use it in GitHub Desktop.
Save synthead/4b464751fa363df4ebe5a58a5e6cef94 to your computer and use it in GitHub Desktop.
#!/bin/bash
ALIAS=unifi
CANAME=root
PASSWORD=aircontrolenterprise
KEYSTORE=/usr/lib/unifi/data/keystore
TEMP_P12_FILE=.${0##*/}.$$.p12
openssl \
pkcs12 \
-export \
-name "$ALIAS" \
-caname "$CANAME" \
-password pass:"$PASSWORD" \
-inkey "$1" \
-in "$2" \
-chain -CAfile "$3" \
-out "$TEMP_P12_FILE"
keytool \
-importkeystore \
-srcstoretype PKCS12 \
-alias "$ALIAS" \
-srcstorepass "$PASSWORD" \
-deststorepass "$PASSWORD" \
-destkeypass "$PASSWORD" \
-destkeystore "$KEYSTORE" \
-srckeystore "$TEMP_P12_FILE"
rm "$TEMP_P12_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment