From a7a6507b5c867b97d700261780a410dc56ae8b96 Mon Sep 17 00:00:00 2001 From: nemetht1 <70274852+nemetht1@users.noreply.github.com> Date: Wed, 28 Jul 2021 11:16:58 +0200 Subject: [PATCH] Create sign-and-upload.sh --- scripts/sign-and-upload.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 scripts/sign-and-upload.sh diff --git a/scripts/sign-and-upload.sh b/scripts/sign-and-upload.sh new file mode 100644 index 0000000..43c68ba --- /dev/null +++ b/scripts/sign-and-upload.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Change this values according to your needs +DGCG_ENDPOINT="https://example.org/rules" +SIGNING_KEY="upload_key.pem" +SIGNING_CERT="upload.pem" +TLS_KEY="auth_key.pem" +TLS_CERT="auth.pem" + +# DO NOT CHANGE ANYTHING BELOW THIS! +function upload() +{ +echo " " +echo "Processing JSON file $1" +java -jar ./dgc-cli.jar signing sign-string -c $SIGNING_CERT -k $SIGNING_KEY -i $1 -o ./tmp.cms +curl --no-progress-bar --request POST "$DGCG_ENDPOINT" --header "Content-Type: application/cms-text" --header "Accept: application/json" --data-binary @tmp.cms --cert "$TLS_CERT" --key "$TLS_KEY" +} + +echo "Search rule files and sign with Upload Certificate and Upload to DGCG" + + +for RULEFILES in `find "./" -type f -name "rule.json"` +do +upload $RULEFILES +done + +echo "" +echo "deleting temporary file" +rm tmp.cms + +exit 1