-
Notifications
You must be signed in to change notification settings - Fork 8
/
c_info
executable file
·36 lines (32 loc) · 1.03 KB
/
c_info
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
#! /bin/sh
# c_info (Bourne shell script) -- Shows info about PEM-format X.509 certificate(s)
#
# Works similar to c_info from the 'openssl' package, but without bugs
#
# Tolerates failure to open a file by not showing anything other than the
# openssl error.
# Accepts "-" as an argument to read that cert from stdin.
# By default, reads a cert from stdin.
#
# Differs from the 'openssl' package's command by also showing the start date
if [ $# -eq 0 ] ; then
set -- -
fi
# Similar to "-nameopt RFC2253" but with semicolons and without dn_rev
OPTS="-nameopt esc_2253,esc_ctrl,esc_msb,utf8,dump_nostr,dump_unknown,dump_der,sep_semi_plus_space,sname"
for file do
if [ -n "$prevfile" ] ; then
echo "--------"
fi
prevfile="$file" # Do this here to avoid missing out in case of openssl error
if [ "$file" = - ] ; then
info="$(openssl x509 -subject -issuer -dates $OPTS -noout)"
else
if ! info="$(openssl x509 -subject -issuer -dates $OPTS -noout -in "$file")"
then
continue
fi
fi
echo "$file"
echo "$info"
done