Program: 52530
Project: 52530
Buggy source:
/** 
 * we generate an intermediate certificate signed by our CA
 */
public static Certificate createIntermediateCert(PublicKey pubKey,PrivateKey caPrivKey,X509Certificate caCert) throws Exception {
  Hashtable attrs=new Hashtable();
  Vector order=new Vector();
  attrs.put(X509Principal.C,"String_Node_Str");
  attrs.put(X509Principal.O,"String_Node_Str");
  attrs.put(X509Principal.OU,"String_Node_Str");
  attrs.put(X509Principal.EmailAddress,"String_Node_Str");
  order.addElement(X509Principal.C);
  order.addElement(X509Principal.O);
  order.addElement(X509Principal.OU);
  order.addElement(X509Principal.EmailAddress);
  v3CertGen.reset();
  v3CertGen.setSerialNumber(BigInteger.valueOf(2));
  v3CertGen.setIssuerDN(PrincipalUtil.getSubjectX509Principal(caCert));
  v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60* 24* 30));
  v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60* 24* 30)));
  v3CertGen.setSubjectDN(new X509Principal(order,attrs));
  v3CertGen.setPublicKey(pubKey);
  v3CertGen.setSignatureAlgorithm("String_Node_Str");
  v3CertGen.addExtension(X509Extensions.SubjectKeyIdentifier,false,new SubjectKeyIdentifierStructure(pubKey));
  v3CertGen.addExtension(X509Extensions.AuthorityKeyIdentifier,false,new AuthorityKeyIdentifierStructure(caCert));
  v3CertGen.addExtension(X509Extensions.BasicConstraints,true,new BasicConstraints(0));
  X509Certificate cert=v3CertGen.generate(caPrivKey);
  cert.checkValidity(new Date());
  cert.verify(caCert.getPublicKey());
  PKCS12BagAttributeCarrier bagAttr=(PKCS12BagAttributeCarrier)cert;
  bagAttr.setBagAttribute(PKCSObjectIdentifiers.pkcs_9_at_friendlyName,new DERBMPString("String_Node_Str"));
  return cert;
}

Fixed version (ground truth):
/** 
 * we generate an intermediate certificate signed by our CA
 */
public static Certificate createIntermediateCert(PublicKey pubKey,PrivateKey caPrivKey,X509Certificate caCert) throws Exception {
  Hashtable attrs=new Hashtable();
  Vector order=new Vector();
  attrs.put(X509Principal.C,"String_Node_Str");
  attrs.put(X509Principal.O,"String_Node_Str");
  attrs.put(X509Principal.OU,"String_Node_Str");
  attrs.put(X509Principal.EmailAddress,"String_Node_Str");
  order.addElement(X509Principal.C);
  order.addElement(X509Principal.O);
  order.addElement(X509Principal.OU);
  order.addElement(X509Principal.EmailAddress);
  v3CertGen.reset();
  v3CertGen.setSerialNumber(BigInteger.valueOf(2));
  v3CertGen.setIssuerDN(PrincipalUtil.getSubjectX509Principal(caCert));
  v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60* 24* 30));
  v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60* 24* 30)));
  v3CertGen.setSubjectDN(new X509Principal(order,attrs));
  v3CertGen.setPublicKey(pubKey);
  v3CertGen.setSignatureAlgorithm("String_Node_Str");
  v3CertGen.addExtension(X509Extensions.SubjectKeyIdentifier,false,new SubjectKeyIdentifierStructure(getDigest(SubjectPublicKeyInfo.getInstance(pubKey.getEncoded()))));
  v3CertGen.addExtension(X509Extensions.AuthorityKeyIdentifier,false,new AuthorityKeyIdentifierStructure(caCert));
  v3CertGen.addExtension(X509Extensions.BasicConstraints,true,new BasicConstraints(0));
  X509Certificate cert=v3CertGen.generate(caPrivKey);
  cert.checkValidity(new Date());
  cert.verify(caCert.getPublicKey());
  PKCS12BagAttributeCarrier bagAttr=(PKCS12BagAttributeCarrier)cert;
  bagAttr.setBagAttribute(PKCSObjectIdentifiers.pkcs_9_at_friendlyName,new DERBMPString("String_Node_Str"));
  return cert;
}