diff --git a/zsh.d/zshfunctions/x509 b/zsh.d/zshfunctions/x509 index a200e17..9250fbf 100644 --- a/zsh.d/zshfunctions/x509 +++ b/zsh.d/zshfunctions/x509 @@ -1,10 +1,12 @@ usage() { echo "x509 " echo "x509 -r " - return 0 } -[ $# -eq 0 ] && return 0 +if [ $# -eq 0 ]; then + usage + return 0 +fi help=0 remote=0 @@ -19,6 +21,22 @@ while getopts ":hr:" arg; do ;; esac done -[ $help -eq 1 ] && usage && return 0 -[ $remote -eq 0 ] && openssl x509 -in $* -noout -text -[ $remote -eq 1 ] && openssl s_client -connect $host < /dev/null | openssl x509 -noout -text + +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 < /dev/null | openssl x509 -noout -text +fi + +# vim: set ts=2 sw=2 tw=0 ft=sh : diff --git a/zsh.d/zshfunctions/x509.zwc b/zsh.d/zshfunctions/x509.zwc index aa552f1..f6732f8 100644 Binary files a/zsh.d/zshfunctions/x509.zwc and b/zsh.d/zshfunctions/x509.zwc differ