Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added use of Proxy server #126

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ssl-cert-check is a Bourne shell script that can be used to report on expiring S
$ ./ssl-cert-check
Usage: ./ssl-cert-check [ -e email address ] [ -E sender email address ] [ -x days ] [-q] [-a] [-b] [-h] [-i] [-n] [-N] [-v]
{ [ -s common_name ] && [ -p port] } || { [ -f cert_file ] } || { [ -c cert file ] } || { [ -d cert dir ] }"
{ [ -P proxy address ] }

-a : Send a warning message through E-mail
-b : Will not print header
Expand All @@ -27,6 +28,7 @@ Usage: ./ssl-cert-check [ -e email address ] [ -E sender email address ] [ -x da
-v : Specify a specific protocol version to use (tls, ssl2, ssl3)
-V : Only print validation data
-x days : Certificate expiration interval (eg. if cert_date < days)
-P proxy : Proxy Utilization (proxy_address:proxy_port)
</pre>

# Examples:
Expand Down
21 changes: 18 additions & 3 deletions ssl-cert-check
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
PROGRAMVERSION=4.14
PROGRAMVERSION=4.15
#
# Program: SSL Certificate Check <ssl-cert-check>
#
Expand All @@ -13,6 +13,9 @@ PROGRAMVERSION=4.14
#
# Revision History:
#
# Version 4.15
# - Added use Proxy server @ilmarkese1966
#
# Version 4.14
# - Fixed HOST / PORT discovery @mhow2
#
Expand Down Expand Up @@ -311,6 +314,9 @@ PKCSDBPASSWD=""
# Type of certificate (PEM, DER, NET) (cmdline: -t)
CERTTYPE="pem"

# Proxy Utilization (cmdline: -P)
PROXY=""

# Location of system binaries
AWK=$(command -v awk)
DATE=$(command -v date)
Expand Down Expand Up @@ -348,6 +354,7 @@ fi
# Return code used by nagios. Initialize to 0.
RETCODE=0


# Certificate counters and minimum difference. Initialize to 0.
SUMMARY_VALID=0
SUMMARY_WILL_EXPIRE=0
Expand Down Expand Up @@ -617,6 +624,7 @@ usage()
{
echo "Usage: $0 [ -e email address ] [-E sender email address] [ -x days ] [-q] [-a] [-b] [-h] [-i] [-n] [-N] [-v]"
echo " { [ -s common_name ] && [ -p port] } || { [ -f cert_file ] } || { [ -c cert file ] } || { [ -d cert dir ] }"
echo " { [ -P proxy address ] }"
echo ""
echo " -a : Send a warning message through E-mail"
echo " -b : Will not print header"
Expand All @@ -637,6 +645,7 @@ usage()
echo " -t type : Specify the certificate type"
echo " -V : Print version information"
echo " -x days : Certificate expiration interval (eg. if cert_date < days)"
echo " -P proxy : Proxy Utilization (proxy_address:proxy_port)"
echo ""
}

Expand Down Expand Up @@ -671,7 +680,12 @@ check_server_status() {
if [ "${TLSSERVERNAME}" = "FALSE" ]; then
OPTIONS="-connect ${1}:${2} $TLSFLAG"
else
OPTIONS="-connect ${1}:${2} -servername ${1} $TLSFLAG"
#OPTIONS="-connect ${1}:${2} -servername ${1} $TLSFLAG"
if [ "${PROXY}" = "" ]; then
OPTIONS="-connect ${1}:${2} -servername ${1} $TLSFLAG"
else
OPTIONS="-connect ${1}:${2} -servername ${1} -proxy ${PROXY} $TLSFLAG"
fi
fi

echo "" | "${OPENSSL}" s_client $OPTIONS 2> "${ERROR_TMP}" 1> "${CERT_TMP}"
Expand Down Expand Up @@ -804,7 +818,7 @@ check_file_status() {
#################################
### Start of main program
#################################
while getopts abc:d:e:E:f:hik:nNp:qs:St:Vx: option
while getopts abc:d:e:E:f:hik:nNp:qs:St:Vx:P: option
do
case "${option}" in
a) ALARM="TRUE";;
Expand All @@ -830,6 +844,7 @@ do
exit 0
;;
x) WARNDAYS=$OPTARG;;
P) PROXY=$OPTARG;;
\?) usage
exit 1;;
esac
Expand Down