+ETCCERTSDIR=/etc/ssl/certs
+
+cleanup() {
+ rm -f "$TEMPBUNDLE"
+ rm -f "$ADDED"
+ rm -f "$REMOVED"
+}
+trap cleanup 0
+
+# Helper files. (Some of them are not simple arrays because we spawn
+# subshells later on.)
+TEMPBUNDLE="$(mktemp -t "${CERTBUNDLE}.tmp.XXXXXX")"
+ADDED="$(mktemp -t "ca-certificates.tmp.XXXXXX")"
+REMOVED="$(mktemp -t "ca-certificates.tmp.XXXXXX")"
+
+# Adds a certificate to the list of trusted ones. This includes a symlink
+# in /etc/ssl/certs to the certificate file and its inclusion into the
+# bundle.
+add() {
+ CERT="$1"
+ PEM="$ETCCERTSDIR/$(basename "$CERT" .crt | sed -e 's/ /_/g' \
+ -e 's/[()]/=/g' \
+ -e 's/,/_/g').pem"
+ if ! test -e "$PEM" || [ "$(readlink "$PEM")" != "$CERT" ]
+ then
+ ln -sf "$CERT" "$PEM"
+ echo +$PEM >> "$ADDED"
+ fi
+ cat "$CERT" >> "$TEMPBUNDLE"
+}
+
+remove() {
+ CERT="$1"
+ PEM="$ETCCERTSDIR/$(basename "$CERT" .crt).pem"
+ if test -L "$PEM"
+ then
+ rm -f "$PEM"
+ echo -$PEM >> "$REMOVED"
+ fi
+}
+
+cd $ETCCERTSDIR