Skip to content

Commit

Permalink
added certmanage tool
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc3nt committed Oct 2, 2014
1 parent c566684 commit aa533af
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tools/certmanage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

_help() {
cat << EOF
usage:
$0 print [icedove|iceweasel]
$0 add [icedove|iceweasel] cert_file cert_name
$0 del [icedove|iceweasel] cer_name
EOF
}

_print_certs() {
echo "Print certificates stored into: $1"
certutil -L -d $1
}

_add_cert() {
cert_file=$1
cert_name=$2
certutil -A -n "${cert_name}" -t "TCu,Cuw,Cuw" -i ${cert_file} -d ${cert8}
}

_del_cert() {
cert_name=$1
cert_db=$2
certutil -D -n ${cert_name} -d ${cert8}
}

_set_cert8() {
if [ "$1" == "iceweasel" ]; then
cert8=$(dirname `find ../ -name "cert8.db" | grep firefox`)

This comment has been minimized.

Copy link
@boyska

boyska Oct 5, 2014

I have some doubts:

  1. why ../ ? Are we in a particular directory? shouldn't the "root" path be /etc/skel/.mozilla/firefox ?
  2. what if there are multiple results? wouldn't something like this below be better?
find $profdir -name cert8.db -exec dirname {} \;
elif [ "$1" == "icedove" ]; then
cert8=$(dirname `find ../ -name "cert8.db" | grep icedove`)
fi
}

if [ "$1" == "add" ] && [ $# -eq 4 ]; then
_set_cert8 $2
cert_file=$3
cert_name=$4
_add_cert $cert_file $cert_name
elif [ "$1" == "print" ] && [ $# -eq 2 ]; then
_set_cert8 $2
_print_certs $cert8
elif [ "$1" == "del" ] && [ $# -eq 3 ]; then
_set_cert8 $2
cert_name=$3
_del_cert $cert_name
else
_help
fi

0 comments on commit aa533af

Please sign in to comment.