Skip to content

Commit

Permalink
Use char array for password
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Dec 17, 2024
1 parent 9709018 commit 8e1152c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/main/java/redis/clients/jedis/SslOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8e1152c

Please sign in to comment.