You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@zookeeper.apache.org by "Julian Chandra Sutadi (Jira)" <ji...@apache.org> on 2026/10/20 11:02:00 UTC

[jira] [Created] (ZOOKEEPER-5108) Client SASL settings set to "true" with trailing whitespace are read as false

Julian Chandra Sutadi created ZOOKEEPER-5108:
------------------------------------------------

             Summary: Client SASL settings set to "true" with trailing whitespace are read as false
                 Key: ZOOKEEPER-5108
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-5108
             Project: ZooKeeper
          Issue Type: Bug
            Reporter: Julian Chandra Sutadi


ZOOKEEPER-3613 made ZKConfig.getBoolean() trim values before parsing, after a client setting "zookeeper.client.secure=true " (trailing space, set as a JVM system property via WebSphere Liberty's bootstrap.properties) silently left TLS disabled.

Two other client settings are read from the same ZKClientConfig but parsed without getBoolean(), so they still have the behaviour that 3613 fixed:
{code:java}
// ZKClientConfig.isSaslClientEnabled()
return Boolean.valueOf(getProperty(ENABLE_CLIENT_SASL_KEY, ENABLE_CLIENT_SASL_DEFAULT));

// SaslServerPrincipal.getServerPrincipal()
String canonicalizeText = clientConfig.getProperty(
    ZKClientConfig.ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME,
    ZKClientConfig.ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME_DEFAULT);
canonicalize = Boolean.parseBoolean(canonicalizeText);{code}
Both settings default to "true". When one is set explicitly to "true " with a trailing space, it evaluates to false, which is the opposite of both the configured value and the default configuration value.

This only happens for values set as JVM system properties (the path in the original ZOOKEEPER-3613 report, e.g. -Dzookeeper.sasl.client="true ") or through ZKClientConfig.setProperty(). Values loaded from a client configuration file are already trimmed in ZKConfig.parseProperties.

*Proposed fix*
Read both through ZKConfig.getBoolean(key, default) so they share the 3613 behaviour:
{code:java}
// ZKClientConfig
public boolean isSaslClientEnabled() {
    return getBoolean(ENABLE_CLIENT_SASL_KEY, Boolean.parseBoolean(ENABLE_CLIENT_SASL_DEFAULT));
}

// SaslServerPrincipal
boolean canonicalize = clientConfig.getBoolean(
    ZKClientConfig.ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME,
    Boolean.parseBoolean(ZKClientConfig.ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME_DEFAULT));{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)