public boolean generateKeyPair(String alias, char[] storePassword, char[] keyPassword, String keyAlgorithm, int keySize, String signatureAlgorithm, int validity, String commonName, String orgUnit, String organization, String locality, String state, String country) {
try {
KeyPairGenerator kpgen = KeyPairGenerator.getInstance(keyAlgorithm);
kpgen.initialize(keySize);
KeyPair keyPair = kpgen.generateKeyPair();
X509Certificate cert = generateCertificate(keyPair.getPublic(), keyPair.getPrivate(), signatureAlgorithm,
validity, commonName, orgUnit, organization, locality, state, country);
keystore.setKeyEntry(alias, keyPair.getPrivate(), keyPassword, new Certificate[] { cert });
privateKeys.add(alias);