Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,10 @@ private static void generateKeystore() {

LOG.debug("Generating keystore at: {}", keystorePath);

Security.addProvider(new BouncyCastleProvider());

String storePassword = generateRandomPassword(Environment.KEYSTORE_PWD_LEN);
String keyPassword = storePassword;

KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "BC");
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(Environment.KEYSTORE_KEY_SIZE);
KeyPair keyPair = keyGen.generateKeyPair();

Expand All @@ -225,7 +223,7 @@ private static void generateKeystore() {

KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(null, null);
keyStore.setKeyEntry(alias, keyPair.getPrivate(), keyPassword.toCharArray(), new java.security.cert.Certificate[]{certificate});
keyStore.setKeyEntry(alias, keyPair.getPrivate(), storePassword.toCharArray(), new java.security.cert.Certificate[]{certificate});

File keystoreFile = new File(keystorePath);
keystoreFile.getParentFile().mkdirs();
Expand All @@ -240,7 +238,7 @@ private static void generateKeystore() {
props.setProperty(Environment.KEYSTORE_PROP_STOREFILE, keystoreFile.getName());
props.setProperty(Environment.KEYSTORE_PROP_STOREPWD, storePassword);
props.setProperty(Environment.KEYSTORE_PROP_KEYALIAS, alias);
props.setProperty(Environment.KEYSTORE_PROP_KEYPWD, keyPassword);
props.setProperty(Environment.KEYSTORE_PROP_KEYPWD, storePassword);

try (FileWriter writer = new FileWriter(propsFile)) {
props.store(writer, "Generated keystore credentials");
Expand Down