From 8e1152c04382a554defd540d3b766c41337cd652 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:42:29 +0600 Subject: [PATCH] Use char array for password --- src/main/java/redis/clients/jedis/SslOptions.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/redis/clients/jedis/SslOptions.java b/src/main/java/redis/clients/jedis/SslOptions.java index 9c98029af7..09b724da97 100644 --- a/src/main/java/redis/clients/jedis/SslOptions.java +++ b/src/main/java/redis/clients/jedis/SslOptions.java @@ -239,12 +239,12 @@ public Builder truststore(File truststore) { * @param truststorePassword the truststore password. May be empty to omit password and the truststore integrity check. * @return {@code this} */ - public Builder truststore(File truststore, String truststorePassword) { + public Builder truststore(File truststore, char[] truststorePassword) { Objects.requireNonNull(truststore, "Truststore must not be null"); assertFile("Truststore", truststore); - return truststore(Resource.from(truststore), getPassword(truststorePassword)); + return truststore(Resource.from(truststore), truststorePassword); } /** @@ -268,11 +268,11 @@ public Builder truststore(URL truststore) { * @param truststorePassword the truststore password. May be empty to omit password and the truststore integrity check. * @return {@code this} */ - public Builder truststore(URL truststore, String truststorePassword) { + public Builder truststore(URL truststore, char[] truststorePassword) { Objects.requireNonNull(truststore, "Truststore must not be null"); - return truststore(Resource.from(truststore), getPassword(truststorePassword)); + return truststore(Resource.from(truststore), truststorePassword); } /** @@ -386,10 +386,6 @@ public SSLParameters getSslParameters() { return sslParameters; } - private static char[] getPassword(String password) { - return password != null ? password.toCharArray() : null; - } - private static char[] getPassword(char[] chars) { return chars != null ? Arrays.copyOf(chars, chars.length) : null; }