File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ SERVERNAME=$( echo $1 | cut -d " :" -f1)
4
+ THE_PORT=$( echo $1 | sed ' s/.*://' )
5
+
6
+ # ## TEST DEPENDENCIES ###
7
+ # -- OPENSSL --#
8
+ command -v openssl > /dev/null 2>&1 || if [[ $? -ne 0 ]] ; then
9
+ echo -e " Error : openssl is missing, please install openssl package."
10
+ exit
11
+ fi
12
+
13
+ # -- PARAMS CHECK --#
14
+ if [[ $SERVERNAME = " " ]]; then
15
+ echo -e " Error, SERVER parameter is missing !"
16
+ echo -e " Usage : get_ssl_cert.sh SERVER:PORT"
17
+ exit
18
+ fi
19
+
20
+ if ! [[ $THE_PORT =~ [0-9] ]]; then
21
+ echo -e " Error, PORT parameter is missing !"
22
+ echo -e " Usage : get_ssl_cert.sh SERVER:PORT"
23
+ exit
24
+ fi
25
+
26
+ echo -n | openssl s_client -servername $SERVERNAME -connect $SERVERNAME :$THE_PORT | openssl x509 > $SERVERNAME .cert
You can’t perform that action at this time.
0 commit comments