mirror of
https://github.com/kakwa/uts-server
synced 2024-12-04 15:05:54 +01:00
modification in timestamp-file.sh script
* implement a -r switch to force removal of an existing tsr * implement a way to kind of check is the response looks like a TSR
This commit is contained in:
parent
15bb7d9792
commit
62c9b56584
@ -73,7 +73,9 @@ success(){
|
||||
trap clean_exit HUP INT TERM
|
||||
TMPREQ=`mktemp`
|
||||
|
||||
while getopts ":lhu:i:o:O:C:" opt; do
|
||||
REMOVE_TS=0
|
||||
|
||||
while getopts ":lhru:i:o:O:C:" opt; do
|
||||
case $opt in
|
||||
h) help;;
|
||||
l) SYSLOG=0;;
|
||||
@ -82,6 +84,7 @@ while getopts ":lhu:i:o:O:C:" opt; do
|
||||
o) OUTPUT_FILE="`readlink -f $OPTARG`";;
|
||||
O) OPENSSL_OPTS="$OPTARG";;
|
||||
C) CURL_OPTS="$OPTARG";;
|
||||
r) REMOVE_TS=1;;
|
||||
\?) echo "Invalid option: -$OPTARG" >&2; help; exit 1;;
|
||||
:) echo "Option -$OPTARG requires an argument." >&2; help; exit 1;;
|
||||
esac
|
||||
@ -93,7 +96,12 @@ done
|
||||
# Check that input file exists
|
||||
[ -f "$INPUT_FILE" ] || exit_error "Input file '$INPUT_FILE' doesn't exist"
|
||||
# Check that output file doesn't exit
|
||||
! [ -f "$OUTPUT_FILE" ] || exit_error "Output timestamp file '$OUTPUT_FILE' already exists"
|
||||
if [ $REMOVE_TS -eq 1 ]
|
||||
then
|
||||
[ -f "$OUTPUT_FILE" ] && rm -f "$OUTPUT_FILE"
|
||||
else
|
||||
! [ -f "$OUTPUT_FILE" ] || exit_error "Output timestamp file '$OUTPUT_FILE' already exists"
|
||||
fi
|
||||
# Check that url is not empty
|
||||
! [ -z "$TS_URL" ] || exit_error "Missing timestamp server url"
|
||||
|
||||
@ -111,6 +119,9 @@ curl "$TS_URL" $CURL_OPTS \
|
||||
--data-binary @$TMPREQ \
|
||||
-o "$OUTPUT_FILE" 2>/dev/null || exit_error "Timestamp query failed"
|
||||
|
||||
openssl ts -verify -data "$INPUT_FILE" -in "$OUTPUT_FILE" 2>&1 | grep -q "asn1 encoding routines" && exit_error \
|
||||
"Reponse doesn't appear to be a timestamp response"
|
||||
|
||||
success "Timestamp of file '$INPUT_FILE' using server '$TS_URL' succeed, ts written to '$OUTPUT_FILE'"
|
||||
|
||||
clean
|
||||
|
Loading…
Reference in New Issue
Block a user