Added type checks

pull/217/head
M66B 9 months ago
parent ed00428cb3
commit 763240bd65

@ -192,9 +192,11 @@ public class EntityCertificate {
Collection<List<?>> altNames = certificate.getSubjectAlternativeNames(); Collection<List<?>> altNames = certificate.getSubjectAlternativeNames();
if (altNames != null) if (altNames != null)
for (List altName : altNames) for (List altName : altNames)
if (altName.get(0).equals(GeneralName.rfc822Name)) if (altName.get(0).equals(GeneralName.rfc822Name)) {
if (altName.get(1) instanceof String)
result.add((String) altName.get(1)); result.add((String) altName.get(1));
else if (altName.get(0).equals(GeneralName.otherName) && altName.get(1) instanceof byte[]) } else if (altName.get(0).equals(GeneralName.otherName)) {
if (altName.get(1) instanceof byte[])
try { try {
ASN1InputStream decoder = new ASN1InputStream((byte[]) altName.get(1)); ASN1InputStream decoder = new ASN1InputStream((byte[]) altName.get(1));
DLTaggedObject encoded = (DLTaggedObject) decoder.readObject(); DLTaggedObject encoded = (DLTaggedObject) decoder.readObject();
@ -210,7 +212,7 @@ public class EntityCertificate {
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
} }
else } else
Log.i("Alt type=" + altName.get(0) + " data=" + altName.get(1)); Log.i("Alt type=" + altName.get(0) + " data=" + altName.get(1));
} catch (CertificateParsingException ex) { } catch (CertificateParsingException ex) {
Log.e(ex); Log.e(ex);
@ -252,9 +254,10 @@ public class EntityCertificate {
for (List altName : altNames) for (List altName : altNames)
try { try {
if (altName.get(0).equals(GeneralName.dNSName)) if (altName.get(0).equals(GeneralName.dNSName)) {
if (altName.get(1) instanceof String)
result.add((String) altName.get(1)); result.add((String) altName.get(1));
else if (altName.get(0).equals(GeneralName.iPAddress)) } else if (altName.get(0).equals(GeneralName.iPAddress))
if (altName.get(1) instanceof String) if (altName.get(1) instanceof String)
result.add((String) altName.get(1)); result.add((String) altName.get(1));
else { else {

Loading…
Cancel
Save