Skip to content

Commit

Permalink
Hook the hostnameverifier for okhttp3 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzion24 committed Jan 20, 2016
1 parent 494f36a commit 41ad183
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/src/main/java/just/trust/me/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,35 @@ protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Thr
// pass
}

//https://github.com/square/okhttp/blob/parent-3.0.1/okhttp/src/main/java/okhttp3/internal/tls/OkHostnameVerifier.java
try {
lpparam.classLoader.loadClass("okhttp3.internal.tls.OkHostnameVerifier");
findAndHookMethod("okhttp3.internal.tls.OkHostnameVerifier", lpparam.classLoader, "verify", String.class, javax.net.ssl.SSLSession.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
return true;
}
});
} catch(ClassNotFoundException e) {
Log.d(TAG, "OKHTTP 3.x not found in " + lpparam.packageName + " -- not hooking OkHostnameVerifier.verify(String, SSLSession)");
// pass
}

//https://github.com/square/okhttp/blob/parent-3.0.1/okhttp/src/main/java/okhttp3/internal/tls/OkHostnameVerifier.java
try {
lpparam.classLoader.loadClass("okhttp3.internal.tls.OkHostnameVerifier");
findAndHookMethod("okhttp3.internal.tls.OkHostnameVerifier", lpparam.classLoader, "verify", String.class, java.security.cert.X509Certificate.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
return true;
}
});
} catch(ClassNotFoundException e) {
Log.d(TAG, "OKHTTP 3.x not found in " + lpparam.packageName + " -- not hooking OkHostnameVerifier.verify(String, X509)(");
// pass
}



/* Only for newer devices should we try to hook TrustManagerImpl */
if (hasTrustManagerImpl()) {
Expand Down

0 comments on commit 41ad183

Please sign in to comment.