1#!/bin/sh
2##
3## Copyright (c) 2000 Proofpoint, Inc. and its suppliers.
4##       All rights reserved.
5##
6## $Id: link_hash.sh,v 1.3 2013-11-22 20:51:18 ca Exp $
7##
8#
9# ln a certificate to its hash
10#
11SSL=openssl
12if test $# -ge 1
13then
14  for i in $@
15  do
16  C=$i.pem
17  test -f $C || C=$i
18  if test -f $C
19  then
20    H=`$SSL x509 -noout -hash < $C`.0
21    if test -h $H -o -f $H
22    then
23      echo link $H to $C exists
24    else
25      ln -s $C $H
26    fi
27  else
28    echo "$0: cannot open $C"
29    exit 2
30  fi
31  done
32else
33  echo "$0: missing name"
34  exit 1
35fi
36exit 0
37