From f77585534a63828fb760552be74484c5038a6003 Mon Sep 17 00:00:00 2001 From: Robert Martin-Legene <robert@nic.ar> Date: Mon, 9 Sep 2019 16:36:47 -0300 Subject: [PATCH] Un script para demonstrar como llamar al API --- bin/tsa2.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 bin/tsa2.sh diff --git a/bin/tsa2.sh b/bin/tsa2.sh new file mode 100755 index 0000000..0157f44 --- /dev/null +++ b/bin/tsa2.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Robert Martin-Legene <robert@nic.ar> +# Copyright 2019, NIC Argentina +# License: GPLv2-only + +TSAHOST=${TSAHOST:-localhost} +TSAPORT=${TSAPORT:-3000} + +function usage +{ + echo "Usage: `basename $0` {stamp|verify} <sha256>" >&2 + exit 1; +} + +op=$1 +hash=$2 +out=$( mktemp ) +trap "rm -f $out" EXIT +test ${#hash} = 64 || usage + +case "$op" in + stamp) + curl --header 'Content-Type: application/json' --data "{\"hashes\":[\"${hash}\"]}" http://${TSAHOST}:${TSAPORT}/stamp + echo + ;; + verify) + curl --silent http://${TSAHOST}:${TSAPORT}/verify/${hash} > $out + rc=$? + if [ $rc != 0 ] + then + echo "curl failed and returned exit code $rc." >&2 + exit $rc + fi + if which jq >/dev/null + then + jq . < $out + else + cat $out + fi + ;; + *) + usage +esac + -- GitLab