hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1574424 - /httpcomponents/httpclient-android/branches/4.3.3-android/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
Date Wed, 05 Mar 2014 11:05:52 GMT
Author: olegk
Date: Wed Mar  5 11:05:52 2014
New Revision: 1574424

URL: http://svn.apache.org/r1574424
Log:
Android specific SNI activation

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

Modified: httpcomponents/httpclient-android/branches/4.3.3-android/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.3-android/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java?rev=1574424&r1=1574423&r2=1574424&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.3-android/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
(original)
+++ httpcomponents/httpclient-android/branches/4.3.3-android/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
Wed Mar  5 11:05:52 2014
@@ -41,6 +41,10 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 
+import android.net.SSLCertificateSocketFactory;
+import android.os.Build;
+import android.util.Log;
+
 /**
  * Layered socket factory for TLS/SSL connections.
  * <p>
@@ -117,6 +121,8 @@ import java.net.Socket;
 @ThreadSafe
 public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactory {
 
+    private static final String TAG = "HttpClient";
+
     public static final String TLS   = "TLS";
     public static final String SSL   = "SSL";
     public static final String SSLV2 = "SSLv2";
@@ -272,6 +278,18 @@ public class SSLConnectionSocketFactory 
             sslsock.setEnabledCipherSuites(supportedCipherSuites);
         }
         prepareSocket(sslsock);
+
+        // 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);
+                }
+                ((SSLCertificateSocketFactory) this.socketfactory).setHostname(sslsock, target);
+            }
+        }
+        // End of Android specific code
+
         sslsock.startHandshake();
         verifyHostname(sslsock, target);
         return sslsock;



Mime
View raw message