Github user geek101 commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/184#discussion_r108835534 --- Diff: src/java/main/org/apache/zookeeper/common/X509Util.java --- @@ -214,45 +237,56 @@ public static X509TrustManager createTrustManager(String trustStoreLocation, Str tmf.init(new CertPathTrustManagerParameters(pbParams)); for (final TrustManager tm : tmf.getTrustManagers()) { - if (tm instanceof X509TrustManager) { + if (tm instanceof X509ExtendedTrustManager) { return new X509ExtendedTrustManager() { - HostnameChecker hostnameChecker = HostnameChecker.getInstance(HostnameChecker.TYPE_TLS); + X509ExtendedTrustManager x509ExtendedTrustManager = (X509ExtendedTrustManager) tm; + HostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(); @Override public X509Certificate[] getAcceptedIssuers() { - return ((X509ExtendedTrustManager) tm).getAcceptedIssuers(); + return x509ExtendedTrustManager.getAcceptedIssuers(); } @Override - public void checkClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException { - hostnameChecker.match(socket.getInetAddress().getHostName(), x509Certificates[0]); - ((X509ExtendedTrustManager) tm).checkClientTrusted(x509Certificates, s, socket); + public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { + if (hostnameVerificationEnabled && shouldVerifyClientHostname) { + hostnameVerifier.verify(socket.getInetAddress().getHostName(), ((SSLSocket) socket).getSession()); --- End diff -- Will the hostname be available on the server side to verify?. How will the server know who this client is, one way is to implement a special HostnameVerifier that can be provide a set of peer hostnames or refer back to QuorumPeer to verify using the QuorumVerifier?.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---