Skip to content

Commit 4e3e52a

Browse files
committed
Determine signing key from asc file
Rather than expecting that downloaded files will be signed with a known key, simply use the key from the signature asc file. The purpose of this validation isn't to validate authenticity. It is only to validate digest.
1 parent bb8a795 commit 4e3e52a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

tasks/download.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@
1414
"description": "Whether to check the integrity of the downloaded file",
1515
"default": true
1616
},
17-
"key_id": {
18-
"type": "String",
19-
"description": "The GPG key ID to use when verifying the download",
20-
"default": "4528B6CD9E61EF26"
21-
},
2217
"key_server": {
2318
"type": "String",
24-
"description": "The GPG keyserver to retrieve the GPG key from",
19+
"description": "The GPG keyserver to retrieve GPG keys from",
2520
"default": "hkp://keyserver.ubuntu.com:11371"
2621
}
2722
},

tasks/download.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ EX_UNAVAILABLE=69
88
verify-file() {
99
local sig="$1"
1010
local doc="$2"
11+
local keyid
1112

1213
# The GPG binary is required to be present in order to perform file download
1314
# verification. If it is not present, return EX_UNAVAILABLE.
@@ -19,8 +20,12 @@ verify-file() {
1920
# The verification key must be present, or it must be possible to download it
2021
# from the keyserver to perform file verification. If it is not present,
2122
# return EX_UNAVAILABLE.
22-
if ! { gpg --list-keys "$PT_key_id" || gpg --keyserver "$PT_key_server" --recv-key "$PT_key_id"; } then
23-
echo "Unable to download verification key ${PT_key_id}"
23+
keyid=$(gpg --list-packets --with-colons "$sig" | awk '/:signature packet:/{print $NF; exit 0}')
24+
if [[ -z "$keyid" ]]; then
25+
echo "Unable to determine verification key from ${sig}"
26+
return "$EX_UNAVAILABLE"
27+
elif ! { gpg --list-keys "$keyid" || gpg --keyserver "$PT_key_server" --recv-key "$keyid"; } then
28+
echo "Unable to download verification key ${keyid}"
2429
return "$EX_UNAVAILABLE"
2530
fi
2631

0 commit comments

Comments
 (0)