Fixed issue trying to hook TrustManagerImpl on older APIs

Older APIs do not have the TrustManagerImpl class, so this checks
if that class is available before attempting to hook.
This commit is contained in:
Jake Valletta
2015-11-04 20:10:40 -05:00
parent 26bc1d8b5a
commit 862716fb7f
2 changed files with 27 additions and 9 deletions

View File

@@ -204,18 +204,36 @@ public class Main implements IXposedHookLoadPackage {
}
});
/* external/conscrypt/src/platform/java/org/conscrypt/TrustManagerImpl.java#217 */
/* public List<X509Certificate> checkServerTrusted(X509Certificate[] chain, String authType, String host) throws CertificateException */
findAndHookMethod("com.android.org.conscrypt.TrustManagerImpl", lpparam.classLoader, "checkServerTrusted", X509Certificate[].class, String.class, String.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
ArrayList<X509Certificate> list = new ArrayList<X509Certificate>();
return list;
}
});
/* Only for newer devices should we try to hook TrustManagerImpl */
if (hasTrustManagerImpl()) {
/* external/conscrypt/src/platform/java/org/conscrypt/TrustManagerImpl.java#217 */
/* public List<X509Certificate> checkServerTrusted(X509Certificate[] chain,
String authType, String host) throws CertificateException */
findAndHookMethod("com.android.org.conscrypt.TrustManagerImpl", lpparam.classLoader,
"checkServerTrusted", X509Certificate[].class, String.class,
String.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
ArrayList<X509Certificate> list = new ArrayList<X509Certificate>();
return list;
}
});
}
} // End Hooks
/* Helpers */
// Check for TrustManagerImpl class
public boolean hasTrustManagerImpl() {
try {
Class.forName("com.android.org.conscrypt.TrustManagerImpl");
} catch(ClassNotFoundException e) {
return false;
}
return true;
}
//Create a SingleClientConnManager that trusts everyone!
public ClientConnectionManager getSCCM() {

Binary file not shown.