From 7401da8503805241a5ccfa8471881adf9921883b Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 21 Jan 2020 12:54:36 +0100 Subject: [PATCH] Improved cert error handling --- app/src/main/java/eu/faircode/email/ActivitySetup.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index 50f2240f9d..d7733d47fc 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -81,6 +81,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.security.SecureRandom; +import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.security.spec.KeySpec; @@ -1043,7 +1044,6 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac String fingerprint = EntityCertificate.getFingerprint(cert); List emails = EntityCertificate.getAltSubjectName(cert); - String subject = EntityCertificate.getSubject(cert); DB db = DB.getInstance(context); for (String email : emails) { @@ -1061,7 +1061,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac protected void onException(Bundle args, Throwable ex) { if (ex instanceof IllegalArgumentException) ToastEx.makeText(ActivitySetup.this, ex.getMessage(), Toast.LENGTH_LONG).show(); - else if (ex instanceof IllegalStateException) + else if (ex instanceof IllegalStateException || ex instanceof CertificateException) ToastEx.makeText(ActivitySetup.this, R.string.title_invalid_key, Toast.LENGTH_LONG).show(); else Log.unexpectedError(getSupportFragmentManager(), ex);