Prevent NPE in SOP when reading certificates

This commit is contained in:
Paul Schaub 2021-06-11 14:38:56 +02:00
parent e587fc46b8
commit 56ddd5e70f
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
1 changed files with 3 additions and 0 deletions

View File

@ -51,6 +51,9 @@ public class SopKeyUtil {
PGPPublicKeyRingCollection collection = PGPainless.readKeyRing()
.keyRingCollection(in, true)
.getPgpPublicKeyRingCollection();
if (collection == null) {
throw new PGPException("Provided file " + file.getName() + " does not contain a certificate.");
}
for (PGPPublicKeyRing keyRing : collection) {
publicKeyRings.add(keyRing);
}