4 if [ "$THREEGATES_CA_BASE" != "" ]; then
5 ca_dir="${THREEGATES_CA_BASE}"
10 if [ -d "$ca_dir" ]; then
18 for i in $(cat raw/IT_TSL_CNS.xml raw/IT_TSL_signed.xml | tr -d '\n' | tr -d '\r' | sed 's@\(</\?tsl:X509Certificate>\)@\n\1@g' | grep '^<tsl:X509Certificate>' | sed 's/<tsl:X509Certificate>//g' | grep -v '^$' | sort | uniq ); do
19 # oname="$(printf "%06d" $ct).pem"
21 ( echo "-----BEGIN CERTIFICATE-----"
22 echo "$i" | sed 's/\(.\{60\}\)/\1\n/g'
23 echo "-----END CERTIFICATE-----" ) | grep -v '^$' > ${ca_dir}/$oname
25 hname="$(cat ${ca_dir}/$oname | md5sum | cut -d ' ' -f 1).pem"
26 mv "${ca_dir}/$oname" "${ca_dir}/$hname"
28 hash="$(cat "${ca_dir}/$hname" | openssl x509 -inform PEM -hash -noout)"
29 link="$(cat "${ca_dir}/$hname" | openssl x509 -inform PEM -issuer -noout | sed 's/^issuer= //g;s@/@~@g')"
32 for n in $(seq 0 100); do
33 if [ -f ${hash}.$n ]; then
36 ln -s "$hname" ${hash}.$n
40 if [ $n -eq 100 ]; then
41 echo "n exceeds maximum value (hash)."
45 for n in $(seq 1 100); do
49 lname="${link}_($n).pem"
52 if [ -f "$lname" ]; then
55 ln -s "$hname" "$lname"
59 if [ $n -eq 100 ]; then
60 echo "n exceeds maximum value (link)."