Created
April 24, 2018 20:33
-
-
Save fijimunkii/8b9830acf86c2af7bfdf597640927d0f to your computer and use it in GitHub Desktop.
install p12 certs to linux nssdb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
set -u | |
set -o pipefail | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
if [ -d "$HOME/.pki/nssdb" ]; then | |
echo "cert db already initialized" | |
exit 1 | |
fi | |
CERT_DB_PASSWORD_FILE=$(mktemp -q) \ | |
&& head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 > $CERT_DB_PASSWORD_FILE \ | |
&& mkdir -p $HOME/.pki/nssdb && certutil -d $HOME/.pki/nssdb -N -f $CERT_DB_PASSWORD_FILE | |
for file in $DIR/cert/*.p12; do | |
[ -e "$file" ] || continue | |
pk12util -d sql:$HOME/.pki/nssdb -i $file -w $file.pass -k $CERT_DB_PASSWORD_FILE | |
done | |
shred -vzn 2 $CERT_DB_PASSWORD_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment