summaryrefslogtreecommitdiffstats
path: root/bin/hostcert
diff options
context:
space:
mode:
Diffstat (limited to 'bin/hostcert')
-rwxr-xr-xbin/hostcert9
1 files changed, 7 insertions, 2 deletions
diff --git a/bin/hostcert b/bin/hostcert
index 561244c..545167a 100755
--- a/bin/hostcert
+++ b/bin/hostcert
@@ -1,3 +1,8 @@
-#!/bin/bash
+#!/bin/sh
+set -eu
+set -o pipefail
-openssl s_client -connect "$1" < /dev/null 2>/dev/null | perl -nle 'print if /BEGIN CERTIFICATE/../END CERTIFICATE/' | openssl x509 -text | perl -nle 'print unless /BEGIN CERTIFICATE/../END CERTIFICATE/'
+host="$1"
+port="${2:-443}"
+
+openssl s_client -connect "$host:$port" < /dev/null 2>/dev/null | perl -nle 'print if /BEGIN CERTIFICATE/../END CERTIFICATE/' | openssl x509 -text | perl -nle 'print unless /BEGIN CERTIFICATE/../END CERTIFICATE/'