Skip to content

Instantly share code, notes, and snippets.

@redneck-f25
Created February 2, 2024 05:34
Show Gist options
  • Save redneck-f25/5b10d503c417a3e13730eb0076e0afdf to your computer and use it in GitHub Desktop.
Save redneck-f25/5b10d503c417a3e13730eb0076e0afdf to your computer and use it in GitHub Desktop.
#!/bin/bash
openssl s_client -showcerts -connect example.org:443 < /dev/null \
| sed -n '/^-----BEGIN CERTIFICATE-----/,/^-----END CERTIFICATE-----/p' \
| {
cert=
while read -r; do
cert+="${REPLY}"$'\n'
if [[ "${REPLY}" == "-----END CERTIFICATE-----" ]]; then
openssl x509 -in - -out - -text <<<"${cert}"
cert=
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment