Skip to content

Instantly share code, notes, and snippets.

@XavM
Last active July 29, 2022 14:00
Show Gist options
  • Save XavM/25126bd2f307beafd71523a64089edf0 to your computer and use it in GitHub Desktop.
Save XavM/25126bd2f307beafd71523a64089edf0 to your computer and use it in GitHub Desktop.
Get Serveur Chain Certs info - subject fingerprint issuer startdate enddate
# DON'T !
# Never ever execute command you do not have control on
# The returned cert could contain ";some malicious commands;" that would be executed by the awk:system
SERVER="google.com"
PORT=443
openssl s_client \
-showcerts \
-connect ${SERVER}:${PORT} \
< /dev/null 2>/dev/null \
| awk '
BEGIN{cert=""}
/^-----BEGIN CERTIFICATE-----$/{
flag=1
}
/^-----END CERTIFICATE-----$/{
flag=0
cert=cert$0
system("echo \"" cert "\" | openssl x509 -subject -fingerprint -issuer -startdate -enddate -noout; echo")
cert=""
}
flag==1{ cert=cert$0"\n" }
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment