1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-23 11:27:57 +01:00

SOP: Ignore marker packets in certificates

This commit is contained in:
Paul Schaub 2021-06-10 16:56:36 +02:00
parent 6b99f0aadc
commit e587fc46b8
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 8 additions and 1 deletions

View file

@ -15,6 +15,7 @@
*/ */
package org.pgpainless.key.collection; package org.pgpainless.key.collection;
import org.bouncycastle.bcpg.MarkerPacket;
import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyRing; import org.bouncycastle.openpgp.PGPKeyRing;
import org.bouncycastle.openpgp.PGPObjectFactory; import org.bouncycastle.openpgp.PGPObjectFactory;
@ -64,6 +65,10 @@ public class PGPKeyRingCollection {
List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>(); List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>();
while ((obj = pgpFact.nextObject()) != null) { while ((obj = pgpFact.nextObject()) != null) {
if (obj instanceof MarkerPacket) {
// Skip marker packets
continue;
}
if (obj instanceof PGPSecretKeyRing) { if (obj instanceof PGPSecretKeyRing) {
secretKeyRings.add((PGPSecretKeyRing) obj); secretKeyRings.add((PGPSecretKeyRing) obj);
} else if (obj instanceof PGPPublicKeyRing) { } else if (obj instanceof PGPPublicKeyRing) {

View file

@ -48,7 +48,9 @@ public class SopKeyUtil {
List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>(); List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>();
for (File file : files) { for (File file : files) {
try (FileInputStream in = new FileInputStream(file)) { try (FileInputStream in = new FileInputStream(file)) {
PGPPublicKeyRingCollection collection = PGPainless.readKeyRing().publicKeyRingCollection(in); PGPPublicKeyRingCollection collection = PGPainless.readKeyRing()
.keyRingCollection(in, true)
.getPgpPublicKeyRingCollection();
for (PGPPublicKeyRing keyRing : collection) { for (PGPPublicKeyRing keyRing : collection) {
publicKeyRings.add(keyRing); publicKeyRings.add(keyRing);
} }