-
-
Save flyfire/0908fb7d160e8bfb9e40de1484498931 to your computer and use it in GitHub Desktop.
OkHttp 3 SSL Handshake Interceptor - Prints TLS Version & Cipher Suite Used
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.util.Log; | |
import java.io.IOException; | |
import okhttp3.CipherSuite; | |
import okhttp3.Handshake; | |
import okhttp3.Response; | |
import okhttp3.TlsVersion; | |
/** Prints TLS Version and Cipher Suite for SSL Calls through OkHttp3 */ | |
public class SSLHandshakeInterceptor implements okhttp3.Interceptor { | |
private static final String TAG = "OkHttp3-SSLHandshake"; | |
@Override | |
public Response intercept(Chain chain) throws IOException { | |
final Response response = chain.proceed(chain.request()); | |
printTlsAndCipherSuiteInfo(response); | |
return response; | |
} | |
private void printTlsAndCipherSuiteInfo(Response response) { | |
if (response != null) { | |
Handshake handshake = response.handshake(); | |
if (handshake != null) { | |
final CipherSuite cipherSuite = handshake.cipherSuite(); | |
final TlsVersion tlsVersion = handshake.tlsVersion(); | |
Log.v(TAG, "TLS: " + tlsVersion + ", CipherSuite: " + cipherSuite); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you please guide how to call this class and verify tls