android: Catch NullPointerException when parsing invalid certificates
This commit is contained in:
+25
-16
@@ -43,29 +43,38 @@ public class TrustedCertificateEntry implements Comparable<TrustedCertificateEnt
|
|||||||
mCert = cert;
|
mCert = cert;
|
||||||
mAlias = alias;
|
mAlias = alias;
|
||||||
|
|
||||||
SslCertificate ssl = new SslCertificate(mCert);
|
try
|
||||||
String o = ssl.getIssuedTo().getOName();
|
|
||||||
String ou = ssl.getIssuedTo().getUName();
|
|
||||||
String cn = ssl.getIssuedTo().getCName();
|
|
||||||
if (!o.isEmpty())
|
|
||||||
{
|
{
|
||||||
mSubjectPrimary = o;
|
SslCertificate ssl = new SslCertificate(mCert);
|
||||||
if (!cn.isEmpty())
|
String o = ssl.getIssuedTo().getOName();
|
||||||
|
String ou = ssl.getIssuedTo().getUName();
|
||||||
|
String cn = ssl.getIssuedTo().getCName();
|
||||||
|
if (!o.isEmpty())
|
||||||
{
|
{
|
||||||
mSubjectSecondary = cn;
|
mSubjectPrimary = o;
|
||||||
|
if (!cn.isEmpty())
|
||||||
|
{
|
||||||
|
mSubjectSecondary = cn;
|
||||||
|
}
|
||||||
|
else if (!ou.isEmpty())
|
||||||
|
{
|
||||||
|
mSubjectSecondary = ou;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!ou.isEmpty())
|
else if (!cn.isEmpty())
|
||||||
{
|
{
|
||||||
mSubjectSecondary = ou;
|
mSubjectPrimary = cn;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mSubjectPrimary = ssl.getIssuedTo().getDName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!cn.isEmpty())
|
catch (NullPointerException ex)
|
||||||
{
|
{
|
||||||
mSubjectPrimary = cn;
|
/* this has been seen in Play Console for certificates for which notBefore apparently
|
||||||
}
|
* can't be parsed (which SslCertificate() does) */
|
||||||
else
|
mSubjectPrimary = cert.getSubjectDN().getName();
|
||||||
{
|
|
||||||
mSubjectPrimary = ssl.getIssuedTo().getDName();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user