Intercept HTTPS Traffic from Android Emulators

Learn how to intercept HTTPS traffic from Android emulators and Android Studio virtual devices

In order to allow the HTTP Debugger to decrypt the SSL traffic from Android Emulators (Android Virtual Devices), you need to install our trusted CA Certificate on your Android Emulator, or ignore the SSL errors in your application.

Method 1: Install the trusted CA Certificate on your Android Emulator

Get the HTTP Debugger Pro CA Certificate from: C:\ProgramData\HTTPDebuggerPro\Cert\SSL
And install it on your device as described in the following article at Stackoverflow.

Method 2: Ignore SSL errors in your application

IMPORTANT: Ensure that you are doing this only in the Debug mode!

Define a helper function to disable certificate errors:

private static void disableSSLCertificateErrors() {
    TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
        public X509Certificate[] getAcceptedIssuers() {
            return null;
        }

        @Override
        public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
            // Not implemented
        }

        @Override
        public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
            // Not implemented
        }
    } };

    try {
        SSLContext sc = SSLContext.getInstance("TLS");

        sc.init(null, trustAllCerts, new java.security.SecureRandom());

        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    } catch (KeyManagementException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
}	
                            

Call helper function before establishing a connection to the server:

public static void getHTML() throws Exception {
    disableSSLCertificateErrors();

    StringBuilder result = new StringBuilder();
    URL url = new URL("https://www.google.com/");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("GET");
    InputStream stream = conn.getInputStream();
    BufferedReader rd = new BufferedReader(new InputStreamReader(stream));
    String line;
    while ((line = rd.readLine()) != null) {
        result.append(line);
    }
    rd.close();
} 
                            

Now you may see the HTTPS/SSL traffic from your Android Emulators.

Download FREE 7-Day Trial