Ensure no trailing data in ExtendedKeyUsage extension
@@ -330,20 +330,20 @@ public List getExtendedKeyUsage()
throws CertificateParsingException
{
byte[] bytes = this.getExtensionBytes("2.5.29.37");
-
- if (bytes != null)
+ if (null == bytes)
{
+ return null;
+ }
+
try
{
- ASN1InputStream dIn = new ASN1InputStream(bytes);
- ASN1Sequence seq = (ASN1Sequence)dIn.readObject();
- List list = new ArrayList();
+ ASN1Sequence seq = ASN1Sequence.getInstance(ASN1Primitive.fromByteArray(bytes));
+ List list = new ArrayList();
for (int i = 0; i != seq.size(); i++)
{
list.add(((ASN1ObjectIdentifier)seq.getObjectAt(i)).getId());
}
-
return Collections.unmodifiableList(list);
}
catch (Exception e)
@@ -352,9 +352,6 @@ public List getExtendedKeyUsage()
}
}
- return null;
- }
-
public int getBasicConstraints()
{
if (basicConstraints != null)
