expiry.add(Calendar.DAY_OF_YEAR, validityDays);
certGen.setNotAfter(expiry.getTime());
certGen.setSubjectDN(new X500Principal("CN=" + caName));
certGen.setPublicKey(pubKey);
certGen.setSignatureAlgorithm("SHA1withRSA");
certGen.addExtension(org.bouncycastle.asn1.x509.X509Extension.subjectKeyIdentifier /*X509Extensions.SubjectKeyIdentifier*/, false, new SubjectKeyIdentifierStructure(pubKey));
certGen.addExtension(org.bouncycastle.asn1.x509.X509Extension.basicConstraints /*X509Extensions.BasicConstraints*/, true, new BasicConstraints(true));
X509Certificate caCert = certGen.generate(privKey);
certGen.addExtension(org.bouncycastle.asn1.x509.X509Extension.authorityKeyIdentifier /*X509Extensions.AuthorityKeyIdentifier*/, false, new AuthorityKeyIdentifierStructure(caCert));
caCert = certGen.generate(privKey);
FileOutputStream newp12 = new FileOutputStream(p12FileName);