提交 0d3ac4a0 编写于 作者: W weijun

8011745: Unknown CertificateChoices

Reviewed-by: vinnie
上级 724ce095
...@@ -161,7 +161,8 @@ public class PKCS7 { ...@@ -161,7 +161,8 @@ public class PKCS7 {
} catch (IOException ioe1) { } catch (IOException ioe1) {
ParsingException pe = new ParsingException( ParsingException pe = new ParsingException(
ioe1.getMessage()); ioe1.getMessage());
pe.initCause(ioe1); pe.initCause(ioe);
pe.addSuppressed(ioe1);
throw pe; throw pe;
} }
} }
...@@ -310,20 +311,27 @@ public class PKCS7 { ...@@ -310,20 +311,27 @@ public class PKCS7 {
len = certVals.length; len = certVals.length;
certificates = new X509Certificate[len]; certificates = new X509Certificate[len];
int count = 0;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
ByteArrayInputStream bais = null; ByteArrayInputStream bais = null;
try { try {
if (certfac == null) byte tag = certVals[i].getTag();
certificates[i] = new X509CertImpl(certVals[i]); // We only parse the normal certificate. Other types of
else { // CertificateChoices ignored.
if (tag == DerValue.tag_Sequence) {
if (certfac == null) {
certificates[count] = new X509CertImpl(certVals[i]);
} else {
byte[] encoded = certVals[i].toByteArray(); byte[] encoded = certVals[i].toByteArray();
bais = new ByteArrayInputStream(encoded); bais = new ByteArrayInputStream(encoded);
certificates[i] = certificates[count] =
(X509Certificate)certfac.generateCertificate(bais); (X509Certificate)certfac.generateCertificate(bais);
bais.close(); bais.close();
bais = null; bais = null;
} }
count++;
}
} catch (CertificateException ce) { } catch (CertificateException ce) {
ParsingException pe = new ParsingException(ce.getMessage()); ParsingException pe = new ParsingException(ce.getMessage());
pe.initCause(ce); pe.initCause(ce);
...@@ -337,6 +345,9 @@ public class PKCS7 { ...@@ -337,6 +345,9 @@ public class PKCS7 {
bais.close(); bais.close();
} }
} }
if (count != len) {
certificates = Arrays.copyOf(certificates, count);
}
} }
// check if crls (implicit tag) are provided (crls are OPTIONAL) // check if crls (implicit tag) are provided (crls are OPTIONAL)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册