fix: use correct GPG key for export

`GPGKeyToEntity` incorrectly assumed that within a keyring with multiple
keys that the first key is verified and should be exported. Look at all
keys and find the one that matches the verified key ID.
This commit is contained in:
Gusted 2025-12-30 05:05:38 +01:00 committed by Mathieu Fenniak
parent 57766d133c
commit e559a5fe6c

View file

@ -111,7 +111,13 @@ func GPGKeyToEntity(ctx context.Context, k *GPGKey) (*openpgp.Entity, error) {
if err != nil {
return nil, err
}
return keys[0], err
for _, key := range keys {
if key.PrimaryKey.KeyIdString() == k.KeyID {
return key, nil
}
}
return nil, fmt.Errorf("key with %s id not found", k.KeyID)
}
// parseSubGPGKey parse a sub Key