-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathc_name
More file actions
executable file
·28 lines (25 loc) · 814 Bytes
/
c_name
File metadata and controls
executable file
·28 lines (25 loc) · 814 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
#! /bin/sh
# c_name (Bourne shell script) -- Shows subject of PEM-format X.509 certificate(s)
#
# Works similar to c_name 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.
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 -subject $OPTS -noout)"
else
if ! info="$(openssl x509 -subject $OPTS -noout -in "$file")"
then
continue
fi
fi
printf '%s\t%s\n' "$file" "$info"
done