diff options
author | Tom Hennen <tom.hennen@gmail.com> | 2015-08-20 22:09:27 -0400 |
---|---|---|
committer | Tom Hennen <tom.hennen@gmail.com> | 2015-08-20 22:09:27 -0400 |
commit | b8e0db68f6821c13baad7e7fa37afad5d296ae20 (patch) | |
tree | d19ae6fe5da02bb738d68dfe8fd8e7b0fe34e4ba | |
parent | 1e1b5ff99b0d0ffb8c5948ba96d01e410905177c (diff) | |
parent | 5bd341fd8a8c069268c60644e2498506e2d7f23d (diff) | |
download | AntennaPod-b8e0db68f6821c13baad7e7fa37afad5d296ae20.zip |
merged from develop
-rw-r--r-- | app/build.gradle | 4 | ||||
-rw-r--r-- | core/build.gradle | 4 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java | 80 |
3 files changed, 84 insertions, 4 deletions
diff --git a/app/build.gradle b/app/build.gradle index 77a1cebba..ed02fa642 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ dependencies { compile 'commons-io:commons-io:2.4' compile 'org.jsoup:jsoup:1.7.3' compile 'com.github.bumptech.glide:glide:3.6.1' - compile 'com.squareup.okhttp:okhttp:2.3.0' - compile 'com.squareup.okhttp:okhttp-urlconnection:2.3.0' + compile 'com.squareup.okhttp:okhttp:2.4.0' + compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' compile 'com.squareup.okio:okio:1.2.0' compile 'de.greenrobot:eventbus:2.4.0' compile 'com.joanzapata.android:android-iconify:1.0.9' diff --git a/core/build.gradle b/core/build.gradle index 14667ba37..46b2e3ce9 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -45,8 +45,8 @@ dependencies { compile 'org.jsoup:jsoup:1.7.3' compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.github.bumptech.glide:okhttp-integration:1.3.0' - compile 'com.squareup.okhttp:okhttp:2.3.0' - compile 'com.squareup.okhttp:okhttp-urlconnection:2.3.0' + compile 'com.squareup.okhttp:okhttp:2.4.0' + compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' compile 'com.squareup.okio:okio:1.2.0' compile 'com.nineoldandroids:library:2.4.0' compile 'de.greenrobot:eventbus:2.4.0' diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java index 012678cd0..9aff7489b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java @@ -1,14 +1,23 @@ package de.danoeh.antennapod.core.service.download; import android.support.annotation.NonNull; +import android.os.Build; import android.util.Log; import com.squareup.okhttp.OkHttpClient; +import java.io.IOException; import java.net.CookieManager; import java.net.CookiePolicy; +import java.net.InetAddress; +import java.net.Socket; +import java.security.GeneralSecurityException; import java.util.concurrent.TimeUnit; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; + import de.danoeh.antennapod.core.BuildConfig; /** @@ -64,6 +73,10 @@ public class AntennapodHttpClient { // configure redirects client.setFollowRedirects(true); client.setFollowSslRedirects(true); + + if(16 <= Build.VERSION.SDK_INT && Build.VERSION.SDK_INT < 21) { + client.setSslSocketFactory(new CustomSslSocketFactory()); + } return client; } @@ -76,4 +89,71 @@ public class AntennapodHttpClient { // does nothing at the moment } } + + private static class CustomSslSocketFactory extends SSLSocketFactory { + + private SSLSocketFactory factory; + + public CustomSslSocketFactory() { + try { + SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); + sslContext.init(null, null, null); + factory= sslContext.getSocketFactory(); + } catch(GeneralSecurityException e) { + e.printStackTrace(); + } + } + + @Override + public String[] getDefaultCipherSuites() { + return factory.getDefaultCipherSuites(); + } + + @Override + public String[] getSupportedCipherSuites() { + return factory.getSupportedCipherSuites(); + } + + public Socket createSocket() throws IOException { + SSLSocket result = (SSLSocket) factory.createSocket(); + configureSocket(result); + return result; + } + + public Socket createSocket(String var1, int var2) throws IOException { + SSLSocket result = (SSLSocket) factory.createSocket(var1, var2); + configureSocket(result); + return result; + } + + public Socket createSocket(Socket var1, String var2, int var3, boolean var4) throws IOException { + SSLSocket result = (SSLSocket) factory.createSocket(var1, var2, var3, var4); + configureSocket(result); + return result; + } + + public Socket createSocket(InetAddress var1, int var2) throws IOException { + SSLSocket result = (SSLSocket) factory.createSocket(var1, var2); + configureSocket(result); + return result; + } + + public Socket createSocket(String var1, int var2, InetAddress var3, int var4) throws IOException { + SSLSocket result = (SSLSocket) factory.createSocket(var1, var2, var3, var4); + configureSocket(result); + return result; + } + + public Socket createSocket(InetAddress var1, int var2, InetAddress var3, int var4) throws IOException { + SSLSocket result = (SSLSocket) factory.createSocket(var1, var2, var3, var4); + configureSocket(result); + return result; + } + + private void configureSocket(SSLSocket s) { + s.setEnabledProtocols(new String[] { "TLSv1.2", "TLSv1.1" } ); + } + + } + } |