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 dd2f8a1352
commit bc402472e8

View file

@ -110,7 +110,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