* @param validToDate Certificate validity period end date
* @param algorithm Signature algorithm for the certificate
* @return issued certificate
*/
private Certificate issueCertificate(X509Name subName, X509Name caName, BigInteger serialNum, PublicKey subPubKey, PrivateKey caPriKey, Date validFromDate, Date validToDate, String algorithm) throws Exception {
AlgorithmIdentifier algId = null;
if("MD2withRSA".equalsIgnoreCase(algorithm))
algId = new AlgorithmIdentifier(PKCSObjectIdentifiers.md2WithRSAEncryption);
else if("MD5withRSA".equalsIgnoreCase(algorithm))
algId = new AlgorithmIdentifier(PKCSObjectIdentifiers.md5WithRSAEncryption);
else if("SHA1withRSA".equalsIgnoreCase(algorithm))
algId = new AlgorithmIdentifier(PKCSObjectIdentifiers.sha1WithRSAEncryption);
else
throw new CertificationAuthorityException("Signature algorithm "+algorithm+" is not supported.");
ASN1InputStream ais = new ASN1InputStream(subPubKey.getEncoded());
DERObject subPubkeyDerObj = ais.readObject();