Files
FSI/conf/ocsp-verify.sh
2026-04-22 00:03:42 +01:00

31 lines
895 B
Bash
Executable File

#!/bin/bash
# OpenVPN passes cert depth as $1
depth=$1
# Only check client certificate (depth 0)
if [ "$depth" -eq 0 ]; then
echo "Checking OCSP for peer_cert=$peer_cert" >> /tmp/ocsp.log
if [ -n "$peer_cert" ]; then
status=$(openssl ocsp -issuer /etc/openvpn/server/ca.crt -cert "$peer_cert" -url http://10.60.0.1:8888 -CAfile /etc/openvpn/server/ca.crt 2>>/tmp/ocsp.log)
echo "OCSP Status: $status" >> /tmp/ocsp.log
if echo "$status" | grep -q "revoked"; then
echo "Result: REVOKED" >> /tmp/ocsp.log
exit 1
fi
if echo "$status" | grep -q "good"; then
echo "Result: GOOD" >> /tmp/ocsp.log
exit 0
fi
echo "Result: UNKNOWN/ERROR" >> /tmp/ocsp.log
exit 1
else
echo "peer_cert is empty!" >> /tmp/ocsp.log
exit 1
fi
fi
exit 0