Skip to content

Commit 65e0089

Browse files
committed
ZOOKEEPER-4958: Fix client hostname verification ignored in server if ssl.authProvider configured
`NettyServerCnxnFactory` uses `TrustManager` from `X509AuthenticationProvider` if `ssl.authProvider` is configured. But `clientHostnameVerificationEnabled` is explicitly set to `false` in construction of `X509AuthenticationProvider`. This cause the server skip hostname verification agaist client certificate. This is reproducible in case of following server configs: * zookeeper.ssl.hostnameVerification: true * zookeeper.ssl.clientHostnameVerification: true * zookeeper.fips-mode: false * zookeeper.ssl.authProvider: x509
1 parent 56969ce commit 65e0089

File tree

3 files changed

+462
-2
lines changed

3 files changed

+462
-2
lines changed

zookeeper-server/src/main/java/org/apache/zookeeper/server/auth/KeyAuthenticationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* See the "Pluggable ZooKeeper authentication" section of the
3838
* "Zookeeper Programmer's Guide" for general details of implementing an
3939
* authentication plugin. e.g.
40-
* http://zookeeper.apache.org/doc/trunk/zookeeperProgrammers.html#sc_ZooKeeperPluggableAuthentication
40+
* http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperPluggableAuthentication
4141
*
4242
* This class looks for a numeric "key" under the /key node.
4343
* Authorization is granted if the user passes in as authorization a number

zookeeper-server/src/main/java/org/apache/zookeeper/server/auth/X509AuthenticationProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public X509AuthenticationProvider() throws X509Exception {
8989
boolean crlEnabled = config.getBoolean(x509Util.getSslCrlEnabledProperty(), Boolean.getBoolean("com.sun.net.ssl.checkRevocation"));
9090
boolean ocspEnabled = config.getBoolean(x509Util.getSslOcspEnabledProperty(), Boolean.parseBoolean(Security.getProperty("ocsp.enable")));
9191
boolean hostnameVerificationEnabled = Boolean.parseBoolean(config.getProperty(x509Util.getSslHostnameVerificationEnabledProperty()));
92+
boolean clientHostnameVerificationEnabled = x509Util.isClientHostnameVerificationEnabled(config);
9293

9394
X509KeyManager km = null;
9495
X509TrustManager tm = null;
@@ -120,7 +121,7 @@ public X509AuthenticationProvider() throws X509Exception {
120121
crlEnabled,
121122
ocspEnabled,
122123
hostnameVerificationEnabled,
123-
false,
124+
clientHostnameVerificationEnabled,
124125
fipsMode);
125126
} catch (TrustManagerException e) {
126127
LOG.error("Failed to create trust manager", e);

0 commit comments

Comments
 (0)