diff --git a/src/github/daneren2005/serverproxy/WebProxy.java b/src/github/daneren2005/serverproxy/WebProxy.java index 8578994..a8f7d39 100644 --- a/src/github/daneren2005/serverproxy/WebProxy.java +++ b/src/github/daneren2005/serverproxy/WebProxy.java @@ -31,18 +31,22 @@ import java.util.Map; import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLSocketFactory; public class WebProxy extends ServerProxy { private static String TAG = WebProxy.class.getSimpleName(); private static List REMOVE_REQUEST_HEADERS = Arrays.asList("Host", "Accept-Encoding", "Referer"); private static List REMOVE_RESPONSE_HEADERS = Arrays.asList("Transfer-Encoding"); + private SSLSocketFactory sslSocketFactory; private HostnameVerifier hostnameVerifier; public WebProxy(Context context) { super(context); } - public WebProxy(Context context, HostnameVerifier hostnameVerifier) { + public WebProxy(Context context, SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier) { super(context); + this.sslSocketFactory = sslSocketFactory; this.hostnameVerifier = hostnameVerifier; } @@ -125,6 +129,17 @@ public void run() { connection.setRequestProperty(header.getKey(), header.getValue()); } } + if(connection instanceof HttpsURLConnection) { + HttpsURLConnection sslConnection = (HttpsURLConnection) connection; + + if(sslSocketFactory != null) { + sslConnection.setSSLSocketFactory(sslSocketFactory); + } + + if(hostnameVerifier != null) { + sslConnection.setHostnameVerifier(hostnameVerifier); + } + } if(connection.getResponseCode() == HttpURLConnection.HTTP_OK || connection.getResponseCode() == HttpURLConnection.HTTP_PARTIAL) { responseHeaders = getHeaders(connection.getHeaderFields());