1
0
Fork 0
mirror of https://github.com/MatomoCamp/matomocamp-companion-android.git synced 2024-09-19 16:13:46 +02:00

Added code to also bypass hostname verification in HttpUtils (required

for HTTPS redirects)
This commit is contained in:
Christophe Beyls 2013-12-28 02:17:26 +01:00
parent eeff608ea7
commit f9747078f6

View file

@ -8,8 +8,10 @@ import java.net.URL;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
@ -33,6 +35,13 @@ public class HttpUtils {
System.setProperty("http.keepAlive", "false");
}
// Bypass hostname verification
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
// Trust all HTTPS certificates
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {