1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-26 13:34:49 +02:00

Catch exceptions on malformed keys

This commit is contained in:
Paul Schaub 2023-06-25 14:08:25 +02:00
parent c213760e6c
commit 0ee913d59a
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -12,6 +12,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import org.bouncycastle.bcpg.sig.RevocationReason;
import org.bouncycastle.openpgp.PGPPublicKey;
@ -193,11 +194,19 @@ public class WebOfTrust implements CertificateAuthority {
certsWithKey.add(cert);
// index synopses
Date expirationDate;
try {
expirationDate = cert.getExpirationDateForUse(KeyFlag.CERTIFY_OTHER);
} catch (NoSuchElementException e) {
// Some keys are malformed and have no KeyFlags
return;
}
certSynopsisMap.put(cert.getFingerprint(),
new CertSynopsis(cert.getFingerprint(),
cert.getExpirationDateForUse(KeyFlag.CERTIFY_OTHER),
expirationDate,
revocationStateFromSignature(cert.getRevocationSelfSignature()),
new HashSet<>(cert.getValidUserIds())));
}
private void findEdges() {