We already know about this assumption / practice using char[]
instead of String
for sensitive data. There are several reasons for this. One of them is to clear confidential data immediately after it is no longer needed:
char[] passwd = passwordProvider.getKeyStorePassword(); KeyStore keystore = KeyStore.getInstance("JKS");
Now the question is: does it make sense (i.e. use char[]
) the sense (in particular, mentioned above) when sensitive data comes to you initially as a String
value? eg:
char[] passwd = passwordProvider.getKeyStorePassword().toCharArray(); KeyStore keystore = KeyStore.getInstance("JKS");
Thanks in advance.
UPDATE2: I will rephrase the question: in this specific context (forget about future changes or something else), does the line "clear the contents of the char array" do any good?
UPDATE1: this is not duplication. Why is char [] preferred over String for passwords? I know what this story is. I ask in this particular context, it still makes sense?
source share