Java HttpsURLConnection and TLS 1.2

You will have to create an SSLContext to set the Protocoll: in Java 1.8: SSLContext sc = SSLContext.getInstance(“TLSv1.2”); // Init the SSLContext with a TrustManager[] and SecureRandom() sc.init(null, trustCerts, new java.security.SecureRandom()); in Java 1.7: SSLContext sc = SSLContext.getInstance(“TLSv1”); // Init the SSLContext with a TrustManager[] and SecureRandom() sc.init(null, trustCerts, new java.security.SecureRandom()); then you just have … Read more

How to override the cipherlist sent to the server by Android when using HttpsURLConnection?

This piece of code is a bit raw. please use with care. public class PreferredCipherSuiteSSLSocketFactory extends SSLSocketFactory { private static final String PREFERRED_CIPHER_SUITE = “TLS_RSA_WITH_AES_128_CBC_SHA”; private final SSLSocketFactory delegate; public PreferredCipherSuiteSSLSocketFactory(SSLSocketFactory delegate) { this.delegate = delegate; } @Override public String[] getDefaultCipherSuites() { return setupPreferredDefaultCipherSuites(this.delegate); } @Override public String[] getSupportedCipherSuites() { return setupPreferredSupportedCipherSuites(this.delegate); } @Override public … Read more