aboutsummaryrefslogtreecommitdiffstats
path: root/.functions
diff options
context:
space:
mode:
authorMathias Bynens <mathias@qiwi.be>2013-03-09 12:18:16 +0100
committerMathias Bynens <mathias@qiwi.be>2013-03-09 12:22:29 +0100
commite216473476495be043cdf7169ba616784995570a (patch)
tree6ae0788b1d21c798f6f71ddab34ea64ae610dc2e /.functions
parent12bb9dac8ee7f4bcdf3e74fcbc0455a04be0211f (diff)
downloaddotfiles-e216473476495be043cdf7169ba616784995570a.tar.gz
dotfiles-e216473476495be043cdf7169ba616784995570a.tar.bz2
dotfiles-e216473476495be043cdf7169ba616784995570a.zip
.functions: Improve `getcertnames`
Follow-up to 12bb9dac8ee7f4bcdf3e74fcbc0455a04be0211f. Many thanks to @dserodio!
Diffstat (limited to '.functions')
-rw-r--r--.functions10
1 files changed, 5 insertions, 5 deletions
diff --git a/.functions b/.functions
index d3ae860..f440be4 100644
--- a/.functions
+++ b/.functions
@@ -82,7 +82,7 @@ function gz() {
# Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL.
# Send a fake UA string for sites that sniff it instead of using the Accept-Encoding header. (Looking at you, ajax.googleapis.com!)
function httpcompression() {
- encoding="$(curl -LIs -H 'User-Agent: Mozilla/5 Gecko' -H 'Accept-Encoding: gzip,deflate,compress,sdch' "$1" | grep '^Content-Encoding:')" && echo "$1 is encoded using ${encoding#* }" || echo "$1 is not using any encoding"
+ local encoding="$(curl -LIs -H 'User-Agent: Mozilla/5 Gecko' -H 'Accept-Encoding: gzip,deflate,compress,sdch' "$1" | grep '^Content-Encoding:')" && echo "$1 is encoded using ${encoding#* }" || echo "$1 is not using any encoding"
}
# Syntax-highlight JSON strings or files
@@ -126,15 +126,15 @@ function getcertnames() {
return 1
fi
- domain="${1}"
+ local domain="${1}"
echo "Testing ${domain}…"
echo # newline
- tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
+ local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
| openssl s_client -connect "${domain}:443" 2>&1);
if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then
- certText=$(echo "${tmp}" \
+ 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:"
@@ -144,7 +144,7 @@ function getcertnames() {
echo "Subject Alternative Name(s):"
echo # newline
echo "${certText}" | grep -A 1 "Subject Alternative Name:" \
- | head -2 | tail -1 | sed "s/DNS://g" | sed "s/ //g" | tr "," "\n"
+ | sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2
return 0
else
echo "ERROR: Certificate not found.";