-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathca-list-certs
More file actions
executable file
·51 lines (41 loc) · 1.36 KB
/
ca-list-certs
File metadata and controls
executable file
·51 lines (41 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -e
source $(dirname $(readlink -f $0))/../lib/ca-functions
usage() {
cat <<__EOT__
Usage: tiny-ca list [options] <common name>|<path to certificate>
Options:
-h, --help Print this helpful message!
-f, --config FILE Use config file instead of $CONFFILE
-t, --type TYPE Certificate type: "server" (default), "client" or "user"
-e, --expiring Show certificates that are expiring within 90 days
__EOT__
}
short="hf:e"
long="help,config:,expiring"
opts=$( getopt -o "$short" -l "$long" -n "$PROGNAME" -- "$@" )
if [ 0 -ne $? ]; then echo; usage; exit 1; fi
eval set -- "$opts";
while :; do
case "$1" in
-h|--help) usage; exit 0;;
-f|--config) shift; CONFFILE="$1"; CONFFILECLI=1; shift;;
-e|--expiring) shift; USER_EXPIRE="1"; shift;;
--) shift; break;;
*) echo "Unknown value '$1'"; exit 1;;
esac
done
# load up the configuration file
ca_load_conf
for group in ca server client user; do
case $group in
ca) echo "Certificate Authorities:";;
server) echo; echo "Server Certificates:";;
client) echo; echo "Client Certificates:";;
user) echo; echo "User Certificates:";;
esac
while read certFile; do
#echo "File: $certFile"
cert_info "$certFile"
done < <(find "$CA_HOME/crt/" -type f -name "*.${group}.crt")
done