X509CertBuilder { public static KeyStore createTemporaryCert(String commonName, String alias, String password) { try { KeyStore keyStore = KeyStore.getInstance("PKCS12"); keyStore.load(null, password.toCharArray()); addKeyPair(keyStore, alias, password.toCharArray(), commonName, null, null, null, null, null, null); return keyStore; } catch (OperatorCreationException | GeneralSecurityException | IOException e) { throw new RuntimeException(e.getMessage(), e); } } private  X509CertBuilder(); static KeyStore createTemporaryCert(String commonName, String alias, String password); static void addKeyPair(
		KeyStore keystore,
		String alias,
		char[] privateKeyPassword,
		String commonName,
		String unit,
		String organization,
		String location,
		String state,
		String country,
		String emailAdress);  }
@Test public void testCreateTemporaryCert() throws Exception { KeyStore keyStore = X509CertBuilder.createTemporaryCert("commonName", "theAlias", "password"); assertEquals(keyStore.getType(), "PKCS12"); assertEquals(keyStore.size(), 1); assertTrue(keyStore.isKeyEntry("theAlias")); Key key = keyStore.getKey("theAlias", "password".toCharArray()); assertEquals(key.getFormat(), "PKCS#8"); }