File tree Expand file tree Collapse file tree 3 files changed +1486
-0
lines changed Expand file tree Collapse file tree 3 files changed +1486
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ while getopts " c:l:e" opt; do
4
+ case $opt in
5
+ c ) export CER_FILE=" $OPTARG " ;;
6
+ l ) export URL_LIST=" $OPTARG " ;;
7
+ e ) export SHOW_ERR=1;;
8
+ * )
9
+ echo " Unknown parameter."
10
+ exit 1
11
+ ;;
12
+ esac
13
+ done
14
+
15
+ if [ $# -eq 0 ] ; then
16
+ echo " Usage: $( basename $0 ) [-c /path/to/certificate/file.pem] [-l path/to/url/list.txt]"
17
+ echo
18
+ echo " -c specify certificate file to test"
19
+ echo " -l specify url list"
20
+ echo " -e show curl errors in log"
21
+ echo
22
+ echo " Example:"
23
+ echo " $( basename $0 ) -c roots.pem -l url_list.txt"
24
+ exit 0
25
+ fi
26
+
27
+ export SHOW_ERR=${SHOW_ERR:- 0}
28
+
29
+ echo
30
+ echo SHOW_ERR=$SHOW_ERR
31
+ echo
32
+
33
+ for i in $( cat $URL_LIST )
34
+ do
35
+ echo -n " $i "
36
+ # -s: silent
37
+ # -S: show error
38
+ # -m: max time
39
+ # --cacert: path to certificate pem file
40
+ # --capath: local certificate path
41
+ # --output: stdout output
42
+ if [ " $SHOW_ERR " -eq 1 ] ; then
43
+ m=$( curl " $i " -s -S -m 60 --cacert $CER_FILE --capath /dev/null --output /dev/null --stderr -)
44
+ else
45
+ curl " $i " -s -m 60 --cacert $CER_FILE --capath /dev/null --output /dev/null
46
+ fi
47
+ # curl --cacert roots.pem --trace-ascii log.log -K url_list.txt
48
+ if [ $? -eq 0 ] ; then
49
+ echo -e " \e[32m PASS \e[39m"
50
+ else
51
+ echo -n -e " \e[31m FAIL \e[39m"
52
+ echo $m
53
+ fi
54
+ done
You can’t perform that action at this time.
0 commit comments