1
0
Fork 0
chezmoi/bin/executable_showcert
2022-05-12 11:31:44 +02:00

20 lines
527 B
Bash

#!/bin/zsh
coproc ( : | openssl s_client -connect $1:443 2>/dev/null| awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/' | openssl x509 -in - -noout -startdate -enddate -ext subjectAltName | sed '/X509v3 Subject Alternative Name/ {n ; s/DNS://g ; s/, /\n /g;}' )
exec 3> >(LC_ALL=C sort)
sort=0
while read -p line
do
if [[ $line = notBefore=* ]]
then
if (( sort == 1 ))
then
echo " $line" >&3
else
[[ $line = 'X509v3 Subject Alternative Name:' ]] && sort=1
echo $line
fi
done