question: private X509Certificate generateX509Certificate ( PrivateKey privateKey ) throws CertificateEncodingException , InvalidKeyException , IllegalStateException , NoSuchAlgorithmException , SignatureException , IOException { if ( version != 3 ) { throw new NotImplementedException ( ) ; } certificateGenerator = new X509V3CertificateGenerator ( ) ; certificateGenerator . setSerialNumber ( serial ) ; certificateGenerator . setIssuerDN ( this . issuer ) ; certificateGenerator . setNotBefore ( notBefore ) ; certificateGenerator . setNotAfter ( notAfter ) ; certificateGenerator . setSubjectDN ( subject ) ; certificateGenerator . setSignatureAlgorithm ( signatureAlgorithm ) ; certificateGenerator . setPublicKey ( publicKey ) ; if ( hasBasicConstraints ) { if ( isCA && hasNoPathLimit ) { certificateGenerator . addExtension ( X509Extensions . BasicConstraints , true , new BasicConstraints ( true ) ) ; } else if ( isCA && ! hasNoPathLimit ) { certificateGenerator . addExtension ( X509Extensions . BasicConstraints , true , new BasicConstraints ( pathLimit ) ) ; } else { certificateGenerator . addExtension ( X509Extensions . BasicConstraints , true , new BasicConstraints ( false ) ) ; } } if ( keyUsage . size ( ) > 0 ) { int allKeyUsages = 0 ; for ( int i : keyUsage ) { allKeyUsages |= i ; } certificateGenerator . addExtension ( X509Extensions . KeyUsage , true , new KeyUsage ( allKeyUsages ) ) ; } if ( extendedKeyUsage . size ( ) > 0 ) { ASN1EncodableVector allExtendedKeyUsages = new ASN1EncodableVector ( ) ; for ( KeyPurposeId i : extendedKeyUsage ) { allExtendedKeyUsages . add ( i ) ; } certificateGenerator . addExtension ( X509Extensions . ExtendedKeyUsage , false , new DERSequence ( allExtendedKeyUsages ) ) ; } if ( subjectAlternativeName . size ( ) > 0 ) { GeneralNames generalNames = new GeneralNames ( subjectAlternativeName . toArray ( new GeneralName [ subjectAlternativeName . size ( ) ] ) ) ; certificateGenerator . addExtension ( X509Extensions . SubjectAlternativeName , true , generalNames ) ; } if ( setSubjectKeyIdentifier == true ) { JcaX509ExtensionUtils j = new JcaX509ExtensionUtils ( ) ; certificateGenerator . addExtension ( X509Extensions . SubjectKeyIdentifier , false , j . createSubjectKeyIdentifier ( publicKey ) ) ; } if ( ! subjectKeyIdentifier . isEmpty ( ) && setSubjectKeyIdentifier == false ) { byte [ ] ski = CertificateHelper . hexStringToByteArray ( subjectKeyIdentifier ) ; SubjectKeyIdentifier aKI = new SubjectKeyIdentifier ( ski ) ; certificateGenerator . addExtension ( X509Extensions . SubjectKeyIdentifier , true , aKI ) ; } if ( issuerAlternativeName . size ( ) > 0 ) { GeneralNames generalNames = new GeneralNames ( issuerAlternativeName . toArray ( new GeneralName [ issuerAlternativeName . size ( ) ] ) ) ; certificateGenerator . addExtension ( X509Extensions . IssuerAlternativeName , true , generalNames ) ; } if ( setAuthorityKeyIdentifier == true && issuerCertificate != null ) { JcaX509ExtensionUtils j = new JcaX509ExtensionUtils ( ) ; certificateGenerator . addExtension ( X509Extensions . AuthorityKeyIdentifier , true , j . createAuthorityKeyIdentifier ( issuerCertificate ) ) ; } if ( ! authorityKeyIdentifier . isEmpty ( ) && setAuthorityKeyIdentifier == false ) { byte [ ] aki = CertificateHelper . hexStringToByteArray ( authorityKeyIdentifier ) ; AuthorityKeyIdentifier aKI = new AuthorityKeyIdentifier ( aki ) ; certificateGenerator . addExtension ( X509Extensions . AuthorityKeyIdentifier , true , aKI ) ; } for ( BurpCertificateExtension e : burpCertificateExtensions ) { ASN1Encodable extension = X509ExtensionUtil . fromExtensionValue ( e . getExtensionValue ( ) ) ; certificateGenerator . addExtension ( e . getOid ( ) , e . isCritical ( ) , extension ) ; } return certificateGenerator . generate ( privateKey ) ; }
target:  Creates a X.509v3 Certificate. The values of "this" object are used for the building process.