aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal
diff options
context:
space:
mode:
authorRoan Hofland <roan.hofland@hotmail.com>2019-10-22 02:06:31 +0200
committerRoan Hofland <roan.hofland@hotmail.com>2019-10-22 02:26:23 +0200
commit68b8317a09705aa90fc4a4ff1321b7cb4bd726e7 (patch)
treedc9ca4b20d7a7b98bfda694aa62cc15c80d2abe9 /org.eclipse.jgit/src/org/eclipse/jgit/lib/internal
parent8e356fc45e2b169572088ebdfb931ca788a5e220 (diff)
downloadjgit-68b8317a09705aa90fc4a4ff1321b7cb4bd726e7.tar.gz
jgit-68b8317a09705aa90fc4a4ff1321b7cb4bd726e7.zip
GpgKeyLocator: Return subkeys instead of the first key for subkeys
Currently when a subkey is configured for signing via the git user.signingkey configuration option the first key from the keyring for this subkey would be returned for use (master key). The code has been changed to return the requested key from the keyring instead. Bug: 552288 Change-Id: I1c1cdf64c1667316a274ff9d829fc2b563797f2a Signed-off-by: Roan Hofland <roan.hofland@hotmail.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/internal')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java
index 11db7c5998..c662ada7cc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java
@@ -202,7 +202,7 @@ class BouncyCastleGpgKeyLocator {
String fingerprint = Hex.toHexString(keyInfo.getFingerprint())
.toLowerCase(Locale.ROOT);
if (fingerprint.endsWith(keyId)) {
- return getFirstPublicKey(keyBlob);
+ return getPublicKey(keyBlob, keyInfo.getFingerprint());
}
}
return null;
@@ -522,6 +522,12 @@ class BouncyCastleGpgKeyLocator {
.getPublicKey();
}
+ private PGPPublicKey getPublicKey(KeyBlob blob, byte[] fingerprint)
+ throws IOException {
+ return ((PublicKeyRingBlob) blob).getPGPPublicKeyRing()
+ .getPublicKey(fingerprint);
+ }
+
private KeyBox readKeyBoxFile(Path keyboxFile) throws IOException,
NoSuchAlgorithmException, NoSuchProviderException,
NoOpenPgpKeyException {