Show certificate information / quick setup

This commit is contained in:
M66B
2021-08-14 09:00:49 +02:00
parent adfcc4b391
commit ce3f3dd387
7 changed files with 169 additions and 80 deletions

View File

@@ -484,7 +484,7 @@ public class EmailService implements AutoCloseable {
Throwable ce = ex;
while (ce != null) {
if (factory != null && ce instanceof CertificateException)
throw new UntrustedException(factory.certificate, ex);
throw new UntrustedException(ex, factory.certificate);
if (ce instanceof IOException)
ioError = true;
ce = ce.getCause();
@@ -1037,10 +1037,10 @@ public class EmailService implements AutoCloseable {
}
}
class UntrustedException extends MessagingException {
static class UntrustedException extends MessagingException {
private X509Certificate certificate;
UntrustedException(@NonNull X509Certificate certificate, @NonNull Exception cause) {
UntrustedException(@NonNull Exception cause, @NonNull X509Certificate certificate) {
super("Untrusted", cause);
this.certificate = certificate;
}
@@ -1049,23 +1049,10 @@ public class EmailService implements AutoCloseable {
return certificate;
}
String getFingerprint() {
try {
if (certificate == null)
return null;
String keyId = EntityCertificate.getKeyId(certificate);
String fingerPrint = EntityCertificate.getFingerprintSha1(certificate);
return fingerPrint + (keyId == null ? "" : "/" + keyId);
} catch (Throwable ex) {
Log.e(ex);
return null;
}
}
@NonNull
@Override
public synchronized String toString() {
return getCause().toString();
}
}
}
}