Skip to content

Commit 43a7d24

Browse files
ghubertpaloDamien LACHAUME / PALO-IT
authored andcommitted
download complete certificate chain
1 parent d2083c0 commit 43a7d24

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

mithril-aggregator-fake/scripts/import.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,34 @@ download_artifacts() {
3131
echo -n "Downloading ${artifact} data: "
3232
tput sc;
3333

34-
for digest in $(jq -r .[].${json_field} < $DATA_DIR/${artifact}s.json);
34+
for field in $(jq -r .[].${json_field} < $DATA_DIR/${artifact}s.json);
3535
do
3636
tput rc;
37-
wget -O $DATA_DIR/${artifact}-${digest}.json --quiet "${url}/${digest}"
37+
wget -O $DATA_DIR/${artifact}-${field}.json --quiet "${url}/${field}"
3838
let "nb=nb+1"
3939
echo -n "$nb "
4040
done
4141
echo
4242
}
4343

44+
download_certificate_chain() {
45+
echo -n "Downloading certificate chain: "
46+
tput sc;
47+
local parent_hash=$(jq -r .[0].hash $DATA_DIR/certificates.json);
48+
local certificate_hash;
49+
50+
until [ -z "$parent_hash" ];
51+
do
52+
certificate_hash=$parent_hash;
53+
wget -O $DATA_DIR/certificate-${certificate_hash}.json --quiet "${BASE_URL}/certificate/${certificate_hash}";
54+
parent_hash=$(jq -r .previous_hash $DATA_DIR/certificate-${certificate_hash}.json);
55+
echo -n "${parent_hash} ";
56+
tput rc;
57+
done
58+
59+
echo "ok ";
60+
}
61+
4462
# MAIN execution
4563

4664
declare -r DATA_DIR=${1:?"No data directory given to download JSON files."};
@@ -54,7 +72,7 @@ export DATA_DIR URL;
5472
clean_directory;
5573

5674
download_list $BASE_URL/certificates certificates
57-
download_artifacts $BASE_URL/certificate certificate "hash"
75+
download_certificate_chain
5876

5977
download_list $BASE_URL/artifact/snapshots snapshots
6078
download_artifacts $BASE_URL/artifact/snapshot snapshot digest

0 commit comments

Comments
 (0)