File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 19
19
# `/usr/local/share/ca-certificates` and rename it to end in `.crt`. Then
20
20
# run `/usr/sbin/update-ca-certificates`
21
21
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] "
24
24
exit 100
25
25
fi
26
26
27
27
HOST=$1
28
28
29
- if [ $# -eq 2 ]; then
29
+ if [ $# -eq 2 ] || [ $# -eq 3 ] ; then
30
30
PORT=$2
31
31
else
32
32
PORT=443
33
33
fi
34
34
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
36
42
37
43
echo " metric result string ${RESULT:- Error: No data} " ;
38
44
echo " metric host string ${HOST:- Error: No data} " ;
39
45
echo " metric port uint32 ${PORT:- Error: No data} " ;
46
+ echo " metric ca_file string ${CA_FILE:- Error: No data} " ;
40
47
exit 0
You can’t perform that action at this time.
0 commit comments