code: public static X509Certificate newX509Certificate(final PublicKey publicKey,
  		final PrivateKey privateKey, final BigInteger serialNumber, final String subject,
  		final String issuer, final String signatureAlgorithm, final Date start, final Date end)
  		throws CertificateEncodingException, InvalidKeyException, IllegalStateException,
  		NoSuchAlgorithmException, SignatureException
  
  	{
  		final X500Principal subjectPrincipal = new X500Principal(subject);
  		final X500Principal issuerPrincipal = new X500Principal(issuer);
  		final X509V3CertificateGenerator certificateGenerator = new X509V3CertificateGenerator();
  		certificateGenerator.setPublicKey(publicKey);
  		certificateGenerator.setSerialNumber(serialNumber);
  		certificateGenerator.setSubjectDN(subjectPrincipal);
  		certificateGenerator.setIssuerDN(issuerPrincipal);
  		certificateGenerator.setNotBefore(start);
  		certificateGenerator.setNotAfter(end);
  		certificateGenerator.setSignatureAlgorithm(signatureAlgorithm);
  		final X509Certificate certificate = certificateGenerator.generate(privateKey);
  		return certificate;
  	}
docs: Factory method for creating a new {@link X509Certificate} object from the given parameters.
  
  @param publicKey
  the public key
  @param privateKey
  the private key
  @param serialNumber
  the serial number
  @param subject
  the subject
  @param issuer
  the issuer
  @param signatureAlgorithm
  the signature algorithm
  @param start
  the start
  @param end
  the end
  @return the new {@link X509Certificate} object
  
  @throws SignatureException
  is thrown if a generic signature error occur
  @throws NoSuchAlgorithmException
  is thrown if a SecureRandomSpi implementation for the specified algorithm is not
  available from the specified provider
  @throws IllegalStateException
  is thrown if an illegal state occurs on the generation process
  @throws InvalidKeyException
  is thrown if initialization of the cypher object fails on the generation process
  @throws CertificateEncodingException
  is thrown whenever an error occurs while attempting to encode a certificate