From c7dc7f755c9174a967fc449f4e030a6f04a36d9a Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sat, 27 Nov 2021 16:03:32 +0100 Subject: [PATCH] KeyAccessor.ViaKeyId: Differentiate between primary key (direct-key sig) and subkey --- .../main/java/org/pgpainless/key/info/KeyAccessor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyAccessor.java b/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyAccessor.java index b4f61090..c27d3531 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyAccessor.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyAccessor.java @@ -110,7 +110,13 @@ public abstract class KeyAccessor { @Override public @Nonnull PGPSignature getSignatureWithPreferences() { - PGPSignature signature = info.getLatestDirectKeySelfSignature(); + PGPSignature signature; + if (key.getPrimaryKeyId() != key.getSubkeyId()) { + signature = info.getCurrentSubkeyBindingSignature(key.getSubkeyId()); + } else { + signature = info.getLatestDirectKeySelfSignature(); + } + if (signature != null) { return signature; }