Skip to content

Commit

Permalink
.functions: Improve getcertnames
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbynens committed Sep 1, 2014
1 parent 90037c0 commit f89753e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions .functions
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,17 @@ function getcertnames() {

if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then
local certText=$(echo "${tmp}" \
| openssl x509 -text -certopt "no_header, no_serial, no_version, \
no_signame, no_validity, no_issuer, no_pubkey, no_sigdump, no_aux");
echo "Common Name:";
echo ""; # newline
echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//";
echo ""; # newline
echo "Subject Alternative Name(s):";
echo ""; # newline
echo "${certText}" | grep -A 1 "Subject Alternative Name:" \
| sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2;
return 0;
| openssl x509 -text -certopt "no_aux, no_header, no_issuer, no_pubkey, \
no_serial, no_sigdump, no_signame, no_validity, no_version");
echo "Common Name:";
echo ""; # newline
echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//" | sed -e "s/\/emailAddress=.*//";
echo ""; # newline
echo "Subject Alternative Name(s):";
echo ""; # newline
echo "${certText}" | grep -A 1 "Subject Alternative Name:" \
| sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2;
return 0;
else
echo "ERROR: Certificate not found.";
return 1;
Expand Down

0 comments on commit f89753e

Please sign in to comment.