blob: 60c28595bd026f2a5f84d986fa1ca7dbbfc9dfcb [file] [log] [blame]
Ralf S. Engelschalld02b48c1998-12-21 10:52:47 +00001#!/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
Ralf S. Engelschalldfeab061998-12-21 11:00:56 +00007if [ "$SSLEAY"x = "x" -o ! -x "$SSLEAY" ]; then
Ralf S. Engelschalld02b48c1998-12-21 10:52:47 +00008 SSLEAY='ssleay'
9 export SSLEAY
10fi
11DIR=/usr/local/ssl
Ralf S. Engelschall58964a41998-12-21 10:56:39 +000012PATH=$DIR/bin:$PATH
Ralf S. Engelschalld02b48c1998-12-21 10:52:47 +000013
Ralf S. Engelschall13e91dd1998-12-22 15:59:57 +000014if [ ! -f "$SSLEAY" ]; then
15 found=0
16 for dir in . `echo $PATH | sed -e 's/:/ /g'`; do
17 if [ -f "$dir/$SSLEAY" ]; then
18 found=1
19 break
20 fi
21 done
22 if [ $found = 0 ]; then
23 echo "c_rehash: rehashing skipped ('ssleay' program still not available)" 1>&2
24 exit 0
25 fi
26fi
27
Ralf S. Engelschalld02b48c1998-12-21 10:52:47 +000028SSL_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=`$SSLEAY 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