Skip to content

Instantly share code, notes, and snippets.

@NiceRath
Created September 30, 2024 15:33
Show Gist options
  • Save NiceRath/9f5de72523e19b7d738c3f62e75aaeed to your computer and use it in GitHub Desktop.
Save NiceRath/9f5de72523e19b7d738c3f62e75aaeed to your computer and use it in GitHub Desktop.
Script to check if website has OCSP enabled or issues with it
#!/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