Skip to content

Commit ef871f9

Browse files
committed
fixup! add ssl_verify.sh
1 parent a0d7964 commit ef871f9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ssl_verify.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,29 @@
1919
# `/usr/local/share/ca-certificates` and rename it to end in `.crt`. Then
2020
# run `/usr/sbin/update-ca-certificates`
2121

22-
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
23-
echo "Usage: $0 <ip> [port]"
22+
if [ $# -ne 1 ] && [ $# -ne 2 ] && [ $# -ne 3 ]; then
23+
echo "Usage: $0 <ip> [port] [ca_file]"
2424
exit 100
2525
fi
2626

2727
HOST=$1
2828

29-
if [ $# -eq 2 ]; then
29+
if [ $# -eq 2 ] || [ $# -eq 3 ]; then
3030
PORT=$2
3131
else
3232
PORT=443
3333
fi
3434

35-
RESULT=`echo | openssl s_client -connect $HOST:$PORT 2>/dev/null | openssl x509 | openssl verify 2>/dev/null | awk '{ gsub("stdin: ", "") ; print $0 }'`
35+
if [ $# -eq 3 ]; then
36+
CA_FILE=$3
37+
RESULT=`echo | openssl s_client -connect $HOST:$PORT 2>/dev/null | openssl x509 | openssl verify -CAfile $CA_FILE 2>/dev/null | awk '{ gsub("stdin: ", "") ; print $0 }'`
38+
else
39+
CA_FILE=''
40+
RESULT=`echo | openssl s_client -connect $HOST:$PORT 2>/dev/null | openssl x509 | openssl verify 2>/dev/null | awk '{ gsub("stdin: ", "") ; print $0 }'`
41+
fi
3642

3743
echo "metric result string ${RESULT:-Error: No data}";
3844
echo "metric host string ${HOST:-Error: No data}";
3945
echo "metric port uint32 ${PORT:-Error: No data}";
46+
echo "metric ca_file string ${CA_FILE:-Error: No data}";
4047
exit 0

0 commit comments

Comments
 (0)