Skip to content
Open
Show file tree
Hide file tree
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 @@ -356,14 +356,18 @@ protected SSLSocketFactory getSocketFactory(String keyStoreLocation,

char[] keyPassphrase = keyStorePassword.toCharArray();
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
keyStore.load(new FileInputStream(keyStoreLocation), keyPassphrase);
try (FileInputStream keyStoreStream = new FileInputStream(keyStoreLocation)) {
keyStore.load(keyStoreStream, keyPassphrase);
}

KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, keyPassphrase);

char[] trustPassphrase = trustStorePassword.toCharArray();
KeyStore trustStore = KeyStore.getInstance(trustStoreType);
trustStore.load(new FileInputStream(trustStoreLocation), trustPassphrase);
try (FileInputStream trustStoreStream = new FileInputStream(trustStoreLocation)) {
trustStore.load(trustStoreStream, trustPassphrase);
}

TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(trustStore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,18 @@ private void setSSL(Map<String, String> parameters, boolean sslEnabled) {
} else {
char[] keyPassphrase = keyStorePassword.toCharArray();
KeyStore ks = KeyStore.getInstance(keyStoreType);
ks.load(new FileInputStream(keyStoreLocation), keyPassphrase);
try (FileInputStream keyStoreStream = new FileInputStream(keyStoreLocation)) {
ks.load(keyStoreStream, keyPassphrase);
}

KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, keyPassphrase);

char[] trustPassphrase = trustStorePassword.toCharArray();
KeyStore tks = KeyStore.getInstance(trustStoreType);
tks.load(new FileInputStream(trustStoreLocation), trustPassphrase);
try (FileInputStream trustStoreStream = new FileInputStream(trustStoreLocation)) {
tks.load(trustStoreStream, trustPassphrase);
}

TrustManagerFactory tmf = TrustManagerFactory
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
Expand Down