From 4d60d43ff86e8c5b07b48310769568572fde5880 Mon Sep 17 00:00:00 2001 From: Andrea Mistrali Date: Tue, 23 Nov 2021 17:34:14 +0100 Subject: [PATCH] Change x509 function to work local and remote --- zsh.d/zshfunctions/x509 | 28 +++++++++++++++++++++++----- zsh.d/zshfunctions/x509.zwc | Bin 560 -> 1560 bytes 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/zsh.d/zshfunctions/x509 b/zsh.d/zshfunctions/x509 index 592fd35..6a4e555 100644 --- a/zsh.d/zshfunctions/x509 +++ b/zsh.d/zshfunctions/x509 @@ -1,5 +1,23 @@ -if [ -r "$1" ]; then - openssl x509 -in $1 -noout -text | less -else - echo "x509 " -fi +usage() { + echo "x509 " + echo "x509 -r " + 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 diff --git a/zsh.d/zshfunctions/x509.zwc b/zsh.d/zshfunctions/x509.zwc index 63ae6abebd8463d9ce90dfd50e67bc0cb13cee30..05406e247ae4cc9855dc876a84fad15e98071770 100644 GIT binary patch literal 1560 zcmdT@Jx?1!5PkRI<3mVsku-?HfJI{m+#nIKA`B8~fJ9MR6d`8;OXkkHJ4X~WfS|w? zxIqHBbWcxbL`6Z*PoSYpnKyfT2$B>@nU&{e_r3YpS%!Y4i&Bb{06GUNZa}>J;xi!`B3tTtk4vU=uuFQ)G$# z*a&g*UG7^hP{_NuFSeY0+O~Pte&ogPhxinMLFx=8OB=EC1gF>+jO75U112YHk@E(* zBJEZvgY7v--=_gAlFJSQHR7dLNv)^EWJw-EPkD}Mqw`GC$KbofP7Ge+BXWxc`io9$ zK41+`cPB3O_IUX&_fqdAjbGH8OZXe|cjO+0UyhtY*+qu$FiMfw`rUY;U*pI<^}Edj z=tzI$%2gG{8@0N6-!aJB zFjw9RqS#;GRY82Z!t7Cd3biA3uGmeExt# zV;D4)A4PTOemwVspc&&lRy#4Guhn`@`8-ww-&a-o>IhTc)b}aBS+B#*czyOi%mPbf zm)KX-d83WNcRt{COKc5vy6kq z?zUE(xi)>}J`Ld(fnkYJW9OF`$0Bx0&8730anN~=33|Y!@SgH+ n^Niz-ljk^Cd1@~EjGv<74m4{ZJi8fhjGMAl*M3>vvC Pdz