Skip to content

Commit c566465

Browse files
authored
Merge pull request #201 from puppetlabs/SOLARCH-533-peadm-checksum-the-download-of-pe-tar
Add PE download signature checking
2 parents a2f449e + 58660ab commit c566465

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tasks/download.json

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
"path": {
99
"type": "String",
1010
"description": "Where to save the downloaded file"
11+
},
12+
"check_download": {
13+
"type": "Boolean",
14+
"description": "Whether to check the integrity of the downloaded file",
15+
"default": true
1116
}
1217
},
1318
"input_method": "environment",

tasks/download.sh

+32
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,35 @@ else
1111
printf '%s\n' "Downloading: ${PT_source}" >&2
1212
curl -f -L -o "$PT_path" "$PT_source"
1313
fi
14+
15+
if [[ "$PT_check_download" == "false" ]]; then
16+
exit 0
17+
fi
18+
19+
if ! which -s gpg ; then
20+
echo "gpg binary required in path for checking download. Skipping check."
21+
exit 0
22+
fi
23+
24+
echo "Importing Puppet gpg public key"
25+
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-key 4528B6CD9E61EF26
26+
if gpg --list-key --fingerprint 4528B6CD9E61EF26 | grep -q -E "D681 +1ED3 +ADEE +B844 +1AF5 +AA8F +4528 +B6CD +9E61 +EF26" ; then
27+
echo "gpg public key imported successfully."
28+
else
29+
echo "Could not import gpg public key - wrong fingerprint."
30+
exit 1
31+
fi
32+
33+
sigpath=${PT_path}.asc
34+
sigsource=${PT_source}.asc
35+
36+
echo "Downloading tarball signature from ${sigsource}..."
37+
curl -f -L -o "${sigpath}" "${sigsource}"
38+
echo "Downloaded tarball signature to ${sigpath}."
39+
echo "Checking tarball signature at ${sigpath}..."
40+
if gpg --verify "${sigpath}" "${PT_path}" ; then
41+
echo "Signature verification succeeded."
42+
else
43+
echo "Signature verification failed, please re-run the installation."
44+
exit 1
45+
fi

0 commit comments

Comments
 (0)