From 55a8fbc1f990c221dcbc7b04aaa67653b0336612 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 28 Jul 2020 15:14:38 +0200 Subject: [PATCH] Key errors are expected --- .../main/java/eu/faircode/email/FragmentCompose.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 307623b6ff..b5c4ff9f3d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -127,6 +127,7 @@ import org.bouncycastle.cms.jcajce.JceCMSContentEncryptorBuilder; import org.bouncycastle.cms.jcajce.JceKeyTransRecipientInfoGenerator; import org.bouncycastle.operator.ContentSigner; import org.bouncycastle.operator.DigestCalculatorProvider; +import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.operator.OutputEncryptor; import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder; @@ -152,6 +153,7 @@ import java.io.OutputStream; import java.net.UnknownHostException; import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; +import java.security.InvalidKeyException; import java.security.PrivateKey; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -2661,8 +2663,12 @@ public class FragmentCompose extends FragmentBase { } }); snackbar.show(); - } else - Log.unexpectedError(getParentFragmentManager(), ex); + } else { + boolean expected = + (ex instanceof OperatorCreationException && + ex.getCause() instanceof InvalidKeyException); + Log.unexpectedError(getParentFragmentManager(), ex, !expected); + } } }.execute(this, args, "compose:s/mime"); }