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>
This commit is contained in:
Roan Hofland 2019-10-22 02:06:31 +02:00
parent 8e356fc45e
commit 68b8317a09
No known key found for this signature in database
GPG Key ID: 69FDC17B7BFDF862
1 changed files with 7 additions and 1 deletions

View File

@ -202,7 +202,7 @@ private PGPPublicKey findPublicKeyByKeyId(KeyBlob keyBlob)
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 @@ private PGPPublicKey getFirstPublicKey(KeyBlob keyBlob) throws IOException {
.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 {