From a186a124db3021820bf48963862ad90d3880ae65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Z=C3=A1hradn=C3=ADk?= Date: Sat, 1 Nov 2014 00:41:00 +0000 Subject: [PATCH] Allow all hostnames for SSL certificates for Online tracking server --- .../src/net/osmand/plus/monitoring/LiveMonitoringHelper.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/LiveMonitoringHelper.java b/OsmAnd/src/net/osmand/plus/monitoring/LiveMonitoringHelper.java index 0e4bfea38e..71745c137a 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/LiveMonitoringHelper.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/LiveMonitoringHelper.java @@ -24,6 +24,8 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; +import org.apache.http.conn.ssl.AllowAllHostnameVerifier; +import org.apache.http.conn.ssl.SSLSocketFactory; import android.content.Context; import android.os.AsyncTask; @@ -138,6 +140,9 @@ public class LiveMonitoringHelper { HttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, 15000); DefaultHttpClient httpclient = new DefaultHttpClient(params); + //allow certificates where hostnames doesn't match CN + SSLSocketFactory sf = (SSLSocketFactory) httpclient.getConnectionManager().getSchemeRegistry().getScheme("https").getSocketFactory(); + sf.setHostnameVerifier(new AllowAllHostnameVerifier()); // Parse the URL and let the URI constructor handle proper encoding of special characters such as spaces URL u = new URL(url); URI uri = new URI(u.getProtocol(), u.getUserInfo(), u.getHost(), u.getPort(), u.getPath(), u.getQuery(), u.getRef());