Skip to content

Instantly share code, notes, and snippets.

@boly38
Created October 20, 2017 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boly38/24ed3f434cbace2bf8c90ff72f782593 to your computer and use it in GitHub Desktop.
Save boly38/24ed3f434cbace2bf8c90ff72f782593 to your computer and use it in GitHub Desktop.
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