8211107: LDAPS communication failure with jdk 1.8.0_181
authorpkoppula
Tue, 02 Oct 2018 21:38:54 +0530
changeset 51993 c0d05cf1d19d
parent 51992 266a89a5d1af
child 51994 7577686cc9bd
8211107: LDAPS communication failure with jdk 1.8.0_181 Reviewed-by: chegar, coffeys, vtewari
src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java	Tue Oct 02 20:52:40 2018 -0700
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java	Tue Oct 02 21:38:54 2018 +0530
@@ -337,17 +337,17 @@
         // then reset the timeout.
         if (socket instanceof SSLSocket) {
             SSLSocket sslSocket = (SSLSocket) socket;
-            int socketTimeout = sslSocket.getSoTimeout();
             if (!IS_HOSTNAME_VERIFICATION_DISABLED) {
                 SSLParameters param = sslSocket.getSSLParameters();
                 param.setEndpointIdentificationAlgorithm("LDAPS");
                 sslSocket.setSSLParameters(param);
             }
             if (connectTimeout > 0) {
+                int socketTimeout = sslSocket.getSoTimeout();
                 sslSocket.setSoTimeout(connectTimeout); // reuse full timeout value
+                sslSocket.startHandshake();
+                sslSocket.setSoTimeout(socketTimeout);
             }
-            sslSocket.startHandshake();
-            sslSocket.setSoTimeout(socketTimeout);
         }
         return socket;
     }