Ralf S. Engelschall | d02b48c | 1998-12-21 10:52:47 +0000 | [diff] [blame] | 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 | |
Ralf S. Engelschall | dfeab06 | 1998-12-21 11:00:56 +0000 | [diff] [blame] | 7 | if [ "$SSLEAY"x = "x" -o ! -x "$SSLEAY" ]; then |
Ralf S. Engelschall | d02b48c | 1998-12-21 10:52:47 +0000 | [diff] [blame] | 8 | SSLEAY='ssleay' |
| 9 | export SSLEAY |
| 10 | fi |
| 11 | DIR=/usr/local/ssl |
Ralf S. Engelschall | 58964a4 | 1998-12-21 10:56:39 +0000 | [diff] [blame] | 12 | PATH=$DIR/bin:$PATH |
Ralf S. Engelschall | d02b48c | 1998-12-21 10:52:47 +0000 | [diff] [blame] | 13 | |
Ralf S. Engelschall | 13e91dd | 1998-12-22 15:59:57 +0000 | [diff] [blame^] | 14 | if [ ! -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 |
| 26 | fi |
| 27 | |
Ralf S. Engelschall | d02b48c | 1998-12-21 10:52:47 +0000 | [diff] [blame] | 28 | SSL_DIR=$DIR/certs |
| 29 | |
| 30 | if [ "$*" = "" ]; then |
| 31 | CERTS=${*:-${SSL_CERT_DIR:-$SSL_DIR}} |
| 32 | else |
| 33 | CERTS=$* |
| 34 | fi |
| 35 | |
| 36 | IFS=': ' |
| 37 | for i in $CERTS |
| 38 | do |
| 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 | ) |
| 61 | done |