usage() { echo "x509 " echo "x509 -r " } if [ $# -eq 0 ]; then usage return 0 fi help=0 remote=0 while getopts ":hr:" arg; do case $arg in r) remote=1 host=$OPTARG hostname=echo $host|cut -d: -f1 ;; h|*) help=1 ;; esac done if [ $help -eq 1 ]; then usage return 0 fi if [ $remote -eq 0 ]; then if [ -f $* ]; then openssl x509 -in $* -noout -text else echo "$* not found" usage return 0 fi else openssl s_client -connect $host -servername $hostname < /dev/null | openssl x509 -noout -text fi # vim: set ts=2 sw=2 tw=0 ft=sh :