mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-23 03:17:58 +01:00
SOP: Ignore marker packets in certificates
This commit is contained in:
parent
6b99f0aadc
commit
e587fc46b8
2 changed files with 8 additions and 1 deletions
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.pgpainless.key.collection;
|
||||
|
||||
import org.bouncycastle.bcpg.MarkerPacket;
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPObjectFactory;
|
||||
|
@ -64,6 +65,10 @@ public class PGPKeyRingCollection {
|
|||
List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>();
|
||||
|
||||
while ((obj = pgpFact.nextObject()) != null) {
|
||||
if (obj instanceof MarkerPacket) {
|
||||
// Skip marker packets
|
||||
continue;
|
||||
}
|
||||
if (obj instanceof PGPSecretKeyRing) {
|
||||
secretKeyRings.add((PGPSecretKeyRing) obj);
|
||||
} else if (obj instanceof PGPPublicKeyRing) {
|
||||
|
|
|
@ -48,7 +48,9 @@ public class SopKeyUtil {
|
|||
List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>();
|
||||
for (File file : files) {
|
||||
try (FileInputStream in = new FileInputStream(file)) {
|
||||
PGPPublicKeyRingCollection collection = PGPainless.readKeyRing().publicKeyRingCollection(in);
|
||||
PGPPublicKeyRingCollection collection = PGPainless.readKeyRing()
|
||||
.keyRingCollection(in, true)
|
||||
.getPgpPublicKeyRingCollection();
|
||||
for (PGPPublicKeyRing keyRing : collection) {
|
||||
publicKeyRings.add(keyRing);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue