v3CertGen.setSubjectDN(dn);
v3CertGen.setPublicKey(keyPair.getPublic());
v3CertGen.setSignatureAlgorithm("MD5withRSA");
final SecureRandom sr = new SecureRandom();
v3CertGen.setSerialNumber(BigInteger.ONE);
X509Certificate certificate = v3CertGen.generate(keyPair.getPrivate(), sr);
//save keystore to a new file
final KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(null, null);
keystore.setKeyEntry(name, keyPair.getPrivate(), KEYSTORE_PASSWORD.toCharArray(),