Catch NPE when fetching non-certificate data

This commit is contained in:
Paul Schaub 2022-03-02 18:34:43 +01:00
parent 2857273580
commit 30e8a55ef6
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -56,6 +56,9 @@ public class Fetch implements Runnable {
WKDAddress address = WKDAddress.fromEmail(email);
try (InputStream inputStream = fetcher.fetch(address)) {
PGPPublicKeyRing cert = PGPainless.readKeyRing().publicKeyRing(inputStream);
if (cert == null) {
throw new CertNotFetchableException("Fetched data does not contain an OpenPGP certificate.");
}
KeyRingInfo info = PGPainless.inspectKeyRing(cert);
List<String> userIds = info.getValidAndExpiredUserIds();