Created
October 20, 2017 11:27
-
-
Save boly38/24ed3f434cbace2bf8c90ff72f782593 to your computer and use it in GitHub Desktop.
quennec.fr/trucs-astuces getCertificate.sh
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
#!/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