Created
September 30, 2024 15:33
-
-
Save NiceRath/9f5de72523e19b7d738c3f62e75aaeed to your computer and use it in GitHub Desktop.
Script to check if website has OCSP enabled or issues with it
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/bash | |
if [ -z "$1" ] | |
then | |
echo 'Provide a hostname of a website to check!' | |
exit 1 | |
fi | |
if [ -z "$2" ] | |
then | |
PORT='443' | |
else | |
PORT="$2" | |
fi | |
set -euo pipefail | |
TARGET="$1" | |
status="$(openssl s_client -connect "${TARGET}:${PORT}" -status </dev/null 2>/dev/null)" | |
if echo "$status" | grep -q 'OCSP response: no response sent' | |
then | |
# OCSP stapling not enabled | |
echo '2' | |
exit 0 | |
fi | |
if echo "$status" | grep -q 'OCSP Response Status: successful' && echo "$status" | grep -q 'Cert Status: good' | |
then | |
echo '1' | |
exit 0 | |
fi | |
echo '0' | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment