8214440: ldap over a TLS connection negotiate failed with "javax.net.ssl.SSLPeerUnverifiedException: hostname of the server '' does not match the hostname in the server's certificate"
authorrobm
Thu, 10 Jan 2019 07:54:16 -0800
changeset 53237 443abf0dc2ed
parent 53236 dece421843f3
child 53238 38716f9d2239
8214440: ldap over a TLS connection negotiate failed with "javax.net.ssl.SSLPeerUnverifiedException: hostname of the server '' does not match the hostname in the server's certificate" Reviewed-by: vtewari, xuelei
src/java.naming/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java	Thu Jan 10 10:15:02 2019 -0500
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java	Thu Jan 10 07:54:16 2019 -0800
@@ -288,7 +288,8 @@
      */
     public void setConnection(Connection ldapConnection, String hostname) {
         this.ldapConnection = ldapConnection;
-        this.hostname = (hostname != null) ? hostname : ldapConnection.host;
+        this.hostname = (hostname == null || hostname.isEmpty())
+            ? ldapConnection.host : hostname;
         originalInputStream = ldapConnection.inStream;
         originalOutputStream = ldapConnection.outStream;
     }