diff --git a/app/src/main/java/eu/faircode/email/EntityCertificate.java b/app/src/main/java/eu/faircode/email/EntityCertificate.java index aa91cb220c..d6c4586fa0 100644 --- a/app/src/main/java/eu/faircode/email/EntityCertificate.java +++ b/app/src/main/java/eu/faircode/email/EntityCertificate.java @@ -218,39 +218,23 @@ public class EntityCertificate { List result = new ArrayList<>(); Collection> altNames = certificate.getSubjectAlternativeNames(); - if (altNames != null) - for (List altName : altNames) - try { - if (altName.get(0).equals(GeneralName.dNSName)) + if (altNames == null) + return result; + + for (List altName : altNames) + try { + if (altName.get(0).equals(GeneralName.dNSName)) + result.add((String) altName.get(1)); + else if (altName.get(0).equals(GeneralName.iPAddress)) + if (altName.get(1) instanceof String) result.add((String) altName.get(1)); - else if (altName.get(0).equals(GeneralName.iPAddress)) - if (altName.get(1) instanceof String) - result.add((String) altName.get(1)); - else { - Object val = altName.get(1); - Log.e("GeneralName.iPAddress type=" + (val == null ? null : val.getClass())); - } - } catch (Throwable ex) { - Log.e(ex); - } - - try { - X500Name name = new JcaX509CertificateHolder(certificate).getSubject(); - if (name != null) - for (RDN rdn : name.getRDNs(BCStyle.CN)) - for (AttributeTypeAndValue tv : rdn.getTypesAndValues()) { - ASN1Encodable enc = tv.getValue(); - if (enc == null) - continue; - String cn = enc.toString(); - if (TextUtils.isEmpty(cn)) - continue; - if (!result.contains(cn)) - result.add(cn); + else { + Object val = altName.get(1); + Log.e("GeneralName.iPAddress type=" + (val == null ? null : val.getClass())); } - } catch (Throwable ex) { - Log.e(ex); - } + } catch (Throwable ex) { + Log.e(ex); + } return result; }