Skip to content

Instantly share code, notes, and snippets.

@afresh1
Last active September 22, 2016 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afresh1/35175ddfec561506200e810ba2cb7ed6 to your computer and use it in GitHub Desktop.
Save afresh1/35175ddfec561506200e810ba2cb7ed6 to your computer and use it in GitHub Desktop.
This script replaces the c_rehash perl script from openssl, at least the main functionality of it. From http://man.openbsd.org/SSL_CTX_load_verify_locations
#!/bin/sh
# replaces the c_rehash perl script from openssl.
# by afresh1
rm -f *.[0-9]* *.r[0-9]*
for c in *.pem; do
[ "$c" = "*.pem" ] && continue
hash=$(openssl x509 -noout -hash -in "$c")
if egrep -q -- '-BEGIN( X509 | TRUSTED | )CERTIFICATE-' "$c"; then
suf=0
while [ -e $hash.$suf ]; do suf=$(( $suf + 1 )); done
ln -s "$c" $hash.$suf
fi
if egrep -q -- '-BEGIN X509 CRL-' "$c"; then
suf=0
while [ -e $hash.r$suf ]; do suf=$(( $suf + 1 )); done
ln -s "$c" $hash.r$suf
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment