Changeset 6601


Ignore:
Timestamp:
Nov 17, 2014, 9:14:03 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1809: Upgrade 3-rd party libraries

Fixes an issue with connecting to "mis-configured" https servers. See http://stackoverflow.com/questions/7615645/ssl-handshake-alert-unrecognized-name-error-since-upgrade-to-java-1-7-0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/ssl/SSLUtil2.java

    r6497 r6601  
    2626import java.io.IOException;
    2727import java.io.InputStream;
     28import java.net.Socket;
    2829import java.security.KeyStore;
    2930import java.security.KeyStoreException;
     
    4344
    4445import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
     46import org.apache.http.protocol.HttpContext;
    4547
    4648import net.sf.basedb.core.BaseException;
     
    236238    }
    237239    SSLContext context = getSSLContext(serverCertificate, clientCertificate, clientCertificatePassword);
    238     SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(context, new AllowAnyHostNameVerifyer());
     240    SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(context, new AllowAnyHostNameVerifyer())
     241    {
     242      /**
     243        Override default socket creation since we want to null out the host name
     244        in order to be able to connect to some "mis-configured" servers. This change
     245        should effectively cause the same behaviour as if jsse.enableSNIExtension=false
     246        has been set.
     247        See http://stackoverflow.com/questions/7615645/ssl-handshake-alert-unrecognized-name-error-since-upgrade-to-java-1-7-0
     248       */
     249      @Override
     250      public Socket createLayeredSocket(Socket socket, String target, int port, HttpContext context)
     251        throws IOException
     252      {
     253        // 'null' instead of 'target'
     254        return super.createLayeredSocket(socket, null, port, context);
     255      }
     256     
     257    };
    239258    return factory;
    240259  }
Note: See TracChangeset for help on using the changeset viewer.