@Override
  public ZooKeeper newZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
      boolean canBeReadOnly) throws Exception {
    if (!this.sslEnabled) {
      return new ZooKeeper(connectString, sessionTimeout, watcher, canBeReadOnly);
    }
    ZKClientConfig clientConfig = new ZKClientConfig();
    clientConfig.setProperty(ZKClientConfig.SECURE_CLIENT, "true");
    clientConfig.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, "org.apache.zookeeper.ClientCnxnSocketNetty");
    ClientX509Util x509Util = new ClientX509Util();
    clientConfig.setProperty(x509Util.getSslKeystoreLocationProperty(), this.keyStoreLocation);
    clientConfig.setProperty(x509Util.getSslKeystorePasswdProperty(), this.keyStorePassword);
    clientConfig.setProperty(x509Util.getSslKeystoreTypeProperty(), this.keyStoreType);
    clientConfig.setProperty(x509Util.getSslTruststoreLocationProperty(), this.trustStoreLocation);
    clientConfig.setProperty(x509Util.getSslTruststorePasswdProperty(), this.trustStorePassword);
    clientConfig.setProperty(x509Util.getSslTruststoreTypeProperty(), this.trustStoreType);
    return new ZooKeeper(connectString, sessionTimeout, watcher, canBeReadOnly, clientConfig);
  }
Factory to create Zookeeper clients with the zookeeper.client.secure enabled,
allowing SSL communication with the Zookeeper server.
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/common/SSLZookeeperFactory.java