From eb93a38cf56358df3b1aa5f8feb1f60e861ba5d2 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 5 Apr 2016 22:12:44 +0200 Subject: [PATCH] HttpDownloader: handle SSL errors like any other download error Since SSLHandshakeException is a subclass of IOException, and all that is happening is rethrowing an Exception, instead pass this one through so it will be handled by the central Downloader error handling. That's currently just a Toast, but it can easily be expanded in the future. --- .../org/fdroid/fdroid/net/HttpDownloader.java | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java b/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java index f9d7ece2b..20dc237f2 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java +++ b/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java @@ -1,7 +1,5 @@ package org.fdroid.fdroid.net; -import android.util.Log; - import com.nostra13.universalimageloader.core.download.BaseImageDownloader; import org.fdroid.fdroid.FDroidApp; @@ -18,7 +16,6 @@ import java.net.MalformedURLException; import java.net.URL; import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLHandshakeException; import info.guardianproject.netcipher.NetCipher; @@ -72,25 +69,18 @@ public class HttpDownloader extends Downloader { return new BufferedInputStream(connection.getInputStream()); } - // Get a remote file. Returns the HTTP response code. - // If 'etag' is not null, it's passed to the server as an If-None-Match - // header, in which case expect a 304 response if nothing changed. - // In the event of a 200 response ONLY, 'retag' (which should be passed - // empty) may contain an etag value for the response, or it may be left - // empty if none was available. + /** + * Get a remote file, checking the HTTP response code. If 'etag' is not + * {@code null}, it's passed to the server as an If-None-Match header, in + * which case expect a 304 response if nothing changed. In the event of a + * 200 response ONLY, 'retag' (which should be passed empty) may contain + * an etag value for the response, or it may be left empty if none was + * available. + */ @Override public void download() throws IOException, InterruptedException { - try { - setupConnection(); - doDownload(); - } catch (SSLHandshakeException e) { - // TODO this should be handled better, it is not internationalised here - throw new IOException( - "A problem occurred while establishing an SSL " + - "connection. If this problem persists, AND you have a " + - "very old device, you could try using http instead of " + - "https for the repo URL." + Log.getStackTraceString(e)); - } + setupConnection(); + doDownload(); } private boolean isSwapUrl() {