Skip to content

Instantly share code, notes, and snippets.

@loplex
Created May 25, 2022 06:07
Show Gist options
  • Save loplex/6b1351d357d279fe42b2a480da41d5e3 to your computer and use it in GitHub Desktop.
Save loplex/6b1351d357d279fe42b2a480da41d5e3 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -xe
endpoint="$1"
# append specification to use port 443 if no port is provided
[[ ! "$endpoint" =~ ^.*:[0-9]+$ ]] && endpoint="${endpoint}:443"
# remove leading protocol if it is provided (e.g. https://)
endpoint="$(echo "$endpoint" | sed -e 's/^[^\:]*\:\/\/*//')"
openssl s_client -showcerts -connect "$endpoint" </dev/null | sed -n -e '/-.BEGIN/,/-.END/ p'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment