Skip to content

Commit 7987d01

Browse files
committed
chore: Fix import of GPG keys when two keys are provided
* chore: Fix import of GPG keys when two keys are provided We were only retrieving the first output of gpg.list keys because previously we were only running import_gpg_keys once. Now that we run it twice we need to ensure that the key we select from the list matches the one we've imported.
1 parent e1dacbc commit 7987d01

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

release_pkgs.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,22 @@ def _setup_rpm_pkg_directories(self, artifacts_path, gpg_key_name, archs=["aarch
189189
def import_gpg_keys(self, private_key, public_key):
190190
gpg = gnupg.GPG()
191191
private_key = base64.b64decode(private_key)
192-
gpg.import_keys(private_key)
192+
import_result = gpg.import_keys(private_key)
193+
if not import_result.fingerprints:
194+
raise Exception("Failed to import private key")
195+
193196
public_key = base64.b64decode(public_key)
194197
gpg.import_keys(public_key)
198+
199+
imported_fingerprint = import_result.fingerprints[0]
195200
data = gpg.list_keys(secret=True)
196-
return (data[0]["fingerprint"], data[0]["uids"][0])
201+
202+
# Find the specific key we just imported by comparing fingerprints
203+
for key in data:
204+
if key["fingerprint"] == imported_fingerprint:
205+
return (key["fingerprint"], key["uids"][0])
206+
207+
raise Exception(f"Could not find imported key with fingerprint {imported_fingerprint}")
197208

198209
def import_multiple_gpg_keys(self, primary_private_key, primary_public_key, secondary_private_key=None, secondary_public_key=None):
199210
"""

0 commit comments

Comments
 (0)