Skip to content

Commit 56a05e5

Browse files
authored
Create CLI_get_ssl_cert.sh
1 parent 4f9504a commit 56a05e5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

CLI_get_ssl_cert.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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

0 commit comments

Comments
 (0)