-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathc_dump
More file actions
executable file
·29 lines (26 loc) · 794 Bytes
/
c_dump
File metadata and controls
executable file
·29 lines (26 loc) · 794 Bytes
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
#! /bin/sh
# c_dump (Bourne shell script) -- Dumps info about PEM-format X.509 certificate(s)
#
# 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.
#
# Uses a pager per file
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 [ "$file" = - ] ; then
info="$(openssl x509 -text $OPTS -noout)"
else
if ! info="$(openssl x509 -text $OPTS -noout -in "$file")"
then
continue
fi
fi
# TO-DO: Uses $file in less prompt
echo "$info" | ${PAGER:-less}
done