Program: 24596
Project: 24596
Buggy source:
@Override public X509Certificate sign(X509Profile x509profile,PKCS10CertificationRequest pkcs10){
  LOGGER.debug("String_Node_Str" + x509profile.name().get());
  try {
    ensureX509ProfileIsAllowed(x509profile);
    List<X509ExtensionHolder> extensions=x509ExtReader.extractRequestedExtensions(pkcs10);
    ensureNoIllegalRequestedExtensions(extensions);
    SubjectKeyIdentifier subjectKeyID=x509ExtBuilder.buildSubjectKeyIdentifier(pkcs10.getPublicKey());
    extensions.add(new X509ExtensionHolder(X509Extensions.SubjectKeyIdentifier,false,subjectKeyID));
    AuthorityKeyIdentifier authKeyID=x509ExtBuilder.buildAuthorityKeyIdentifier(certificate().getPublicKey());
    extensions.add(new X509ExtensionHolder(X509Extensions.AuthorityKeyIdentifier,false,authKeyID));
    if (x509profile.basicConstraints().get().subjectIsCA().get()) {
      BasicConstraints bc=x509ExtBuilder.buildCABasicConstraints(x509profile.basicConstraints().get().pathLengthConstraint().get());
      extensions.add(new X509ExtensionHolder(X509Extensions.BasicConstraints,x509profile.basicConstraints().get().critical().get(),bc));
    }
 else {
      BasicConstraints bc=x509ExtBuilder.buildNonCABasicConstraints();
      extensions.add(new X509ExtensionHolder(X509Extensions.BasicConstraints,x509profile.basicConstraints().get().critical().get(),bc));
    }
    KeyUsage keyUsages=x509ExtBuilder.buildKeyUsages(x509profile.keyUsages().get().keyUsages().get());
    extensions.add(new X509ExtensionHolder(X509Extensions.KeyUsage,x509profile.keyUsages().get().critical().get(),keyUsages));
    ExtendedKeyUsage extendedKeyUsage=x509ExtBuilder.buildExtendedKeyUsage(x509profile.extendedKeyUsages().get().extendedKeyUsages().get());
    extensions.add(new X509ExtensionHolder(X509Extensions.ExtendedKeyUsage,x509profile.extendedKeyUsages().get().critical().get(),extendedKeyUsage));
    NetscapeCertType netscapeCertType=x509ExtBuilder.buildNetscapeCertTypes(x509profile.netscapeCertTypes().get().netscapeCertTypes().get());
    extensions.add(new X509ExtensionHolder(MiscObjectIdentifiers.netscapeCertType,x509profile.netscapeCertTypes().get().critical().get(),netscapeCertType));
    X509Certificate certificate=x509Generator.generateX509Certificate(privateKey(),certificate().getSubjectX500Principal(),BigInteger.probablePrime(120,new SecureRandom()),pkcs10.getCertificationRequestInfo().getSubject(),pkcs10.getPublicKey(),Duration.standardDays(365),extensions);
    return certificate;
  }
 catch (  GeneralSecurityException ex) {
    LOGGER.error(ex.getMessage(),ex);
    throw new QiPkiFailure("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
@Override public X509Certificate sign(X509Profile x509profile,PKCS10CertificationRequest pkcs10){
  LOGGER.debug("String_Node_Str" + x509profile.name().get());
  try {
    ensureX509ProfileIsAllowed(x509profile);
    List<X509ExtensionHolder> extensions=x509ExtReader.extractRequestedExtensions(pkcs10);
    ensureNoIllegalRequestedExtensions(extensions);
    SubjectKeyIdentifier subjectKeyID=x509ExtBuilder.buildSubjectKeyIdentifier(pkcs10.getPublicKey());
    extensions.add(new X509ExtensionHolder(X509Extensions.SubjectKeyIdentifier,false,subjectKeyID));
    AuthorityKeyIdentifier authKeyID=x509ExtBuilder.buildAuthorityKeyIdentifier(certificate().getPublicKey());
    extensions.add(new X509ExtensionHolder(X509Extensions.AuthorityKeyIdentifier,false,authKeyID));
    if (x509profile.basicConstraints().get().subjectIsCA().get()) {
      BasicConstraints bc=x509ExtBuilder.buildCABasicConstraints(x509profile.basicConstraints().get().pathLengthConstraint().get());
      extensions.add(new X509ExtensionHolder(X509Extensions.BasicConstraints,x509profile.basicConstraints().get().critical().get(),bc));
    }
 else {
      BasicConstraints bc=x509ExtBuilder.buildNonCABasicConstraints();
      extensions.add(new X509ExtensionHolder(X509Extensions.BasicConstraints,x509profile.basicConstraints().get().critical().get(),bc));
    }
    KeyUsage keyUsages=x509ExtBuilder.buildKeyUsages(x509profile.keyUsages().get().keyUsages().get());
    extensions.add(new X509ExtensionHolder(X509Extensions.KeyUsage,x509profile.keyUsages().get().critical().get(),keyUsages));
    ExtendedKeyUsage extendedKeyUsage=x509ExtBuilder.buildExtendedKeyUsage(x509profile.extendedKeyUsages().get().extendedKeyUsages().get());
    extensions.add(new X509ExtensionHolder(X509Extensions.ExtendedKeyUsage,x509profile.extendedKeyUsages().get().critical().get(),extendedKeyUsage));
    NetscapeCertType netscapeCertType=x509ExtBuilder.buildNetscapeCertTypes(x509profile.netscapeCertTypes().get().netscapeCertTypes().get());
    extensions.add(new X509ExtensionHolder(MiscObjectIdentifiers.netscapeCertType,x509profile.netscapeCertTypes().get().critical().get(),netscapeCertType));
    X509Certificate certificate=x509Generator.generateX509Certificate(privateKey(),certificate().getSubjectX500Principal(),BigInteger.probablePrime(120,new SecureRandom()),pkcs10.getCertificationRequestInfo().getSubject(),pkcs10.getPublicKey(),Duration.standardDays(x509profile.validityDays().get()),extensions);
    return certificate;
  }
 catch (  GeneralSecurityException ex) {
    LOGGER.error(ex.getMessage(),ex);
    throw new QiPkiFailure("String_Node_Str",ex);
  }
}