hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1648606 - in /httpcomponents/httpclient-android/branches/4.3.5-android: RELEASE_NOTES.txt src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
Date Tue, 30 Dec 2014 21:36:55 GMT
Author: olegk
Date: Tue Dec 30 21:36:55 2014
New Revision: 1648606

URL: http://svn.apache.org/r1648606
Log:
HTTPCLIENT-1591: invoke Android specific SNI method via reflection

Modified:
    httpcomponents/httpclient-android/branches/4.3.5-android/RELEASE_NOTES.txt
    httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java

Modified: httpcomponents/httpclient-android/branches/4.3.5-android/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/RELEASE_NOTES.txt?rev=1648606&r1=1648605&r2=1648606&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/RELEASE_NOTES.txt Tue Dec 30
21:36:55 2014
@@ -1,6 +1,9 @@
 Changes since 4.3.5
 -------------------
 
+* [HTTPCLIENT-1591] Invoke Android specific SNI method via reflection
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCLIENT-1566] Fixed broken Base64 encoding in BasicScheme
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 

Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java?rev=1648606&r1=1648605&r2=1648606&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
(original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
Tue Dec 30 21:36:55 2014
@@ -28,7 +28,6 @@
 package org.apache.http.conn.ssl;
 
 import android.annotation.TargetApi;
-import android.net.SSLCertificateSocketFactory;
 import android.os.Build;
 import android.util.Log;
 
@@ -42,7 +41,10 @@ import org.apache.http.util.TextUtils;
 import javax.net.SocketFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 
@@ -146,7 +148,7 @@ public class SSLConnectionSocketFactory
      */
     public static SSLConnectionSocketFactory getSocketFactory() throws SSLInitializationException
{
         return new SSLConnectionSocketFactory(
-            (javax.net.ssl.SSLSocketFactory) SSLCertificateSocketFactory.getDefault(-1),
+            (javax.net.ssl.SSLSocketFactory) SSLSocketFactory.getDefault(),
             BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
     }
 
@@ -168,7 +170,7 @@ public class SSLConnectionSocketFactory
      */
     public static SSLConnectionSocketFactory getSystemSocketFactory() throws SSLInitializationException
{
         return new SSLConnectionSocketFactory(
-            (javax.net.ssl.SSLSocketFactory) SSLCertificateSocketFactory.getDefault(-1),
+            (javax.net.ssl.SSLSocketFactory) SSLSocketFactory.getDefault(),
             split(System.getProperty("https.protocols")),
             split(System.getProperty("https.cipherSuites")),
             BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
@@ -286,11 +288,16 @@ public class SSLConnectionSocketFactory
 
         // Android specific code to enable SNI
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
-            if (this.socketfactory instanceof SSLCertificateSocketFactory) {
+            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                Log.d(TAG, "Enabling SNI for " + target);
+            }
+            try {
+                Method method = sslsock.getClass().getMethod("setHostname", String.class);
+                method.invoke(sslsock, target);
+            } catch (Exception ex) {
                 if (Log.isLoggable(TAG, Log.DEBUG)) {
-                    Log.d(TAG, "Enabling SNI for " + target);
+                    Log.d(TAG, "SNI configuration failed", ex);
                 }
-                ((SSLCertificateSocketFactory) this.socketfactory).setHostname(sslsock, target);
             }
         }
         // End of Android specific code



Mime
View raw message