Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
quennec.fr/trucs-astuces getCertificate.sh
#!/bin/sh
# source d'origine: src: https://www.quennec.fr/trucs-astuces/syst%C3%A8mes/gnulinux/commandes/openssl/openssl-r%C3%A9cup%C3%A9rer-un-certificat-distant
# améliorations:
# - quitter après 2 secondes
# - report du stdout
HOST=$1
PORT=${2:-443}
openssl s_client -connect ${HOST}:${PORT} > .workout &
CONNECTPID=$!
sleep 2
kill $CONNECTPID
# prevent output from kill
wait $CONNECTPID 2>/dev/null
cat .workout | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
rm .workout
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.