1
0
mirror of https://github.com/akelge/zsh synced 2025-07-03 05:05:28 +00:00

Change x509 function to work local and remote

This commit is contained in:
2021-11-23 17:34:14 +01:00
parent 115a35d1ae
commit 4d60d43ff8
2 changed files with 23 additions and 5 deletions

View File

@ -1,5 +1,23 @@
if [ -r "$1" ]; then
openssl x509 -in $1 -noout -text | less
else
echo "x509 <certfile>"
fi
usage() {
echo "x509 <certfile>"
echo "x509 -r <hostname:port>"
return
}
[ $# -eq 0 ] && usage
remote=0
while getopts ":hr:" arg; do
case $arg in
r)
remote=1
host=$OPTARG
;;
h) usage
;;
esac
done
[ $remote -eq 0 ] && openssl x509 -in $* -noout -text
[ $remote -eq 1 ] && openssl s_client -connect $host < /dev/null | openssl x509 -noout -text

Binary file not shown.