From 9f530d78db5b82d9a95d2a46e743cae8afb6d53f Mon Sep 17 00:00:00 2001 From: William Hirigoyen Date: Thu, 1 Feb 2024 16:44:51 +0100 Subject: [PATCH] evolinux-base: addd cert.sh, a small readonly openssl wrapper (testing, not deployed yet) --- evolinux-base/files/cert.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 evolinux-base/files/cert.sh diff --git a/evolinux-base/files/cert.sh b/evolinux-base/files/cert.sh new file mode 100644 index 00000000..2782ec15 --- /dev/null +++ b/evolinux-base/files/cert.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Shortcut to show certificate content or enddate. +# + +usage() { + echo "Usage : cert [date] " +} + +if [ "$#" -eq 1 ]; then + cert_path=$1 + if [ -f "${cert_path}" ]; then + openssl x509 -noout -in "${cert_path}" -text + else + >&2 echo "Error, file ${cert_path} does not exist." + fi + +elif [ "$#" -eq 2 ]; then + if [ "$1" = "date" ]; then + cert_path=$2 + if [ -f "${cert_path}" ]; then + openssl x509 -noout -in "$cert_path" -enddate + else + >&2 echo "Error, file ${cert_path} does not exist." + fi + else + >&2 echo "Error, two arguments provided but 'date' is only allowed as first." + usage + exit 1 + fi + +else + >&2 echo "Error, more than two arguments provided." + usage + exit 1 +fi