public Certificate issueCertificate(X500Principal subject, PublicKey publicKey, BigInteger sNo, Date validFromDate, Date validToDate, String algorithm) throws CertificationAuthorityException{
if(isLocked()) throw new CertificationAuthorityException("CA is locked.");
try {
X509Name subName = CaUtils.getX509Name(subject);
Certificate cert = issueCertificate(subName, caName, sNo, publicKey, caPrivateKey, validFromDate, validToDate, algorithm);
cert.verify(caPublicKey);
certStore.storeCertificate(cert);
return cert;
} catch(Exception e) {
throw new CertificationAuthorityException("Error in issuing certificate.", e);
}