1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-05 03:55:58 +01:00

Catch exceptions on malformed keys

This commit is contained in:
Paul Schaub 2023-06-25 14:08:25 +02:00
parent ab0835d176
commit ffae298142
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() {