99ab7ebaa18777d81cea29d7034382dad2712067
[openssl.git] / tools / c_rehash
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
7 if [ "$SSLEAY"x = "x" -o ! -x "$SSLEAY" ]; then
8         SSLEAY='ssleay'
9         export SSLEAY
10 fi
11 DIR=/usr/local/ssl
12 PATH=$DIR/bin:$PATH
13
14 SSL_DIR=$DIR/certs
15
16 if [ "$*" = "" ]; then
17         CERTS=${*:-${SSL_CERT_DIR:-$SSL_DIR}}
18 else
19         CERTS=$*
20 fi
21
22 IFS=': '
23 for i in $CERTS
24 do
25   (
26   IFS=' '
27   if [ -d $i -a -w $i ]; then
28     cd $i
29     echo "Doing $i"
30     for i in *.pem
31     do
32       if [ $i != '*.pem' ]; then
33         h=`$SSLEAY x509 -hash -noout -in $i`
34         if [ "x$h" = "x" ]; then
35           echo $i does not contain a certificate
36         else
37           if [ -f $h.0 ]; then
38             /bin/rm -f $h.0
39           fi
40           echo "$i => $h.0"
41           ln -s $i $h.0
42         fi
43       fi
44     done
45   fi
46   )
47 done