1#!/bin/sh 2# 3# redo the hashes for the certificates in your cert path or the ones passed 4# on the command line. 5# 6 7if [ "$OPENSSL"x = "x" -o ! -x "$OPENSSL" ]; then 8 OPENSSL='openssl' 9 export OPENSSL 10fi 11DIR=/usr/local/ssl 12PATH=$DIR/bin:$PATH 13 14if [ ! -f "$OPENSSL" ]; then 15 found=0 16 for dir in . `echo $PATH | sed -e 's/:/ /g'`; do 17 if [ -f "$dir/$OPENSSL" ]; then 18 found=1 19 break 20 fi 21 done 22 if [ $found = 0 ]; then 23 echo "c_rehash: rehashing skipped ('openssl' program not available)" 1>&2 24 exit 0 25 fi 26fi 27 28SSL_DIR=$DIR/certs 29 30if [ "$*" = "" ]; then 31 CERTS=${*:-${SSL_CERT_DIR:-$SSL_DIR}} 32else 33 CERTS=$* 34fi 35 36IFS=': ' 37for i in $CERTS 38do 39 ( 40 IFS=' ' 41 if [ -d $i -a -w $i ]; then 42 cd $i 43 echo "Doing $i" 44 for i in *.pem 45 do 46 if [ $i != '*.pem' ]; then 47 h=`$OPENSSL x509 -hash -noout -in $i` 48 if [ "x$h" = "x" ]; then 49 echo $i does not contain a certificate 50 else 51 if [ -f $h.0 ]; then 52 /bin/rm -f $h.0 53 fi 54 echo "$i => $h.0" 55 ln -s $i $h.0 56 fi 57 fi 58 done 59 fi 60 ) 61done 62