удаление закрепления SSL на Android - PullRequest
0 голосов
/ 07 сентября 2018

Привет У меня есть ситуация, когда я хочу удалить SSL pinning в приложении Android.

Вот код, который у меня есть, который делает SSL pinning.

private AsyncHttpClient m_asyncHttpClient;
m_asyncHttpClient.setSSLSocketFactory(getSSLSocketFactory());

private static SSLSocketFactory getSSLSocketFactory(){
    try {
        // Get an instance of the Bouncy Castle KeyStore format
        KeyStore trusted = KeyStore.getInstance("BKS");
        // Get the raw resource, which contains the pinnedcert with
        // your trusted certificates (root and any intermediate certs)
        InputStream in = DPApp.getInstance().getResources().openRawResource(R.raw.XXXXX);
        try {
            // Initialize the pinnedcert with the provided trusted certificates
            // Also provide the password of the pinnedcert
            trusted.load(in, "XXX".toCharArray());
            trusted.size();
        } finally {
            in.close();
        }
        // Pass the pinnedcert to the SSLSocketFactory. The factory is responsible
        // for the verification of the server certificate.
        SSLSocketFactory sf = new SSLSocketFactory(trusted);
        // Hostname verification from certificate
        // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d4e506
        sf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
        return sf;
    } catch (Exception e) {
        throw new AssertionError(e);
    }
}

Я пытался прокомментировать строку setSSLSocketFactory, но это дало мне ошибку

java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

Я знаю, что срок действия сервера certificate истек, но сейчас я просто хочу удалить SSL закрепления из приложения.

Любые предложения о том, как лучше всего это сделать из кода Android, пожалуйста.

...