Last active
August 12, 2019 20:35
-
-
Save kritchie/58b9f14f06455942f61ee371556f46ba to your computer and use it in GitHub Desktop.
Bash snippets
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
# | |
# Get TLS certificates expiration | |
# Useful to verify when TLS certificates will expire | |
readonly BLUE='\033[0;34m' | |
readonly RED='\033[0;31m' | |
readonly NC='\033[0m' # No Color | |
validate(){ | |
if [[ -z "$1" || -z "$2" ]]; then | |
echo "Validate needs 2 arguments: validate [host] [port]" | |
return | |
fi | |
HOST=$1 | |
PORT=$2 | |
VAL=$(echo | openssl s_client -connect ${HOST}:${PORT} 2>/dev/null | openssl x509 -noout -dates | grep notAfter) | |
AFTER=$(echo -e "${VAL} ${HOST}" | awk '{split($0,a,"="); split(a[2],b,"GMT"); print b[1]}') | |
URL=$(echo -e "${VAL} ${HOST}" | awk '{split($0,a,"="); split(a[2],b,"GMT"); print b[2]}') | |
echo -e "${RED} ${AFTER} ${BLUE} ${URL} ${NC}" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment