android: Catch NullPointerException when parsing invalid certificates

This commit is contained in:
Tobias Brunner
2017-09-04 10:41:24 +02:00
parent e59b78254a
commit 1a9261a923
@@ -43,6 +43,8 @@ public class TrustedCertificateEntry implements Comparable<TrustedCertificateEnt
mCert = cert; mCert = cert;
mAlias = alias; mAlias = alias;
try
{
SslCertificate ssl = new SslCertificate(mCert); SslCertificate ssl = new SslCertificate(mCert);
String o = ssl.getIssuedTo().getOName(); String o = ssl.getIssuedTo().getOName();
String ou = ssl.getIssuedTo().getUName(); String ou = ssl.getIssuedTo().getUName();
@@ -68,6 +70,13 @@ public class TrustedCertificateEntry implements Comparable<TrustedCertificateEnt
mSubjectPrimary = ssl.getIssuedTo().getDName(); mSubjectPrimary = ssl.getIssuedTo().getDName();
} }
} }
catch (NullPointerException ex)
{
/* this has been seen in Play Console for certificates for which notBefore apparently
* can't be parsed (which SslCertificate() does) */
mSubjectPrimary = cert.getSubjectDN().getName();
}
}
/** /**
* The main subject of this certificate (O, CN or the complete DN, whatever * The main subject of this certificate (O, CN or the complete DN, whatever