Last active
July 29, 2022 14:00
-
-
Save XavM/25126bd2f307beafd71523a64089edf0 to your computer and use it in GitHub Desktop.
Get Serveur Chain Certs info - subject fingerprint issuer startdate enddate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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