RFR: 8354469: Keytool exposes the password in plain text when command is piped using | grep

Naoto Sato naoto at openjdk.org
Wed Sep 10 16:31:54 UTC 2025


On Wed, 10 Sep 2025 15:43:52 GMT, Weijun Wang <weijun at openjdk.org> wrote:

> Allow password hiding even if there is no `System.console`. A manual test is included.

src/java.base/share/classes/sun/security/util/Password.java line 158:

> 156:                     c2 = null;
> 157:                     charset = null;
> 158:                 }

Can be simplified as:

c2 = JdkConsoleImpl.passwordConsole().orElse(null);
charset = (c2 != null) ? c2.charset() : null;

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27196#discussion_r2337290982


More information about the client-libs-dev mailing list