use of okhttp3.ConnectionSpec in project okhttp by square.
the class ConnectionSpecTest method tlsBuilder_explicitCiphers.
@Test
public void tlsBuilder_explicitCiphers() throws Exception {
ConnectionSpec tlsSpec = new ConnectionSpec.Builder(true).cipherSuites(CipherSuite.TLS_RSA_WITH_RC4_128_MD5).tlsVersions(TlsVersion.TLS_1_2).supportsTlsExtensions(true).build();
assertThat(tlsSpec.cipherSuites()).containsExactly(CipherSuite.TLS_RSA_WITH_RC4_128_MD5);
assertThat(tlsSpec.tlsVersions()).containsExactly(TlsVersion.TLS_1_2);
assertThat(tlsSpec.supportsTlsExtensions()).isTrue();
}
use of okhttp3.ConnectionSpec in project okhttp by square.
the class ConnectionSpecTest method tls_explicitCiphers.
@Test
public void tls_explicitCiphers() throws Exception {
platform.assumeNotConscrypt();
platform.assumeNotBouncyCastle();
ConnectionSpec tlsSpec = new ConnectionSpec.Builder(true).cipherSuites(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256).tlsVersions(TlsVersion.TLS_1_2).supportsTlsExtensions(false).build();
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
socket.setEnabledCipherSuites(new String[] { CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256.javaName(), CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA.javaName() });
socket.setEnabledProtocols(new String[] { TlsVersion.TLS_1_2.javaName(), TlsVersion.TLS_1_1.javaName() });
assertThat(tlsSpec.isCompatible(socket)).isTrue();
applyConnectionSpec(tlsSpec, socket, true);
assertThat(socket.getEnabledProtocols()).containsExactly(TlsVersion.TLS_1_2.javaName());
List<String> expectedCipherSuites = new ArrayList<>();
expectedCipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256.javaName());
if (asList(socket.getSupportedCipherSuites()).contains("TLS_FALLBACK_SCSV")) {
expectedCipherSuites.add("TLS_FALLBACK_SCSV");
}
assertThat(socket.getEnabledCipherSuites()).containsExactlyElementsOf(expectedCipherSuites);
}
use of okhttp3.ConnectionSpec in project okhttp by square.
the class CipherSuiteTest method applyIntersectionRetainsSslPrefixes.
@Test
public void applyIntersectionRetainsSslPrefixes() throws Exception {
FakeSslSocket socket = new FakeSslSocket();
socket.setEnabledProtocols(new String[] { "TLSv1" });
socket.setSupportedCipherSuites(new String[] { "SSL_A", "SSL_B", "SSL_C", "SSL_D", "SSL_E" });
socket.setEnabledCipherSuites(new String[] { "SSL_A", "SSL_B", "SSL_C" });
ConnectionSpec connectionSpec = new ConnectionSpec.Builder(true).tlsVersions(TlsVersion.TLS_1_0).cipherSuites("TLS_A", "TLS_C", "TLS_E").build();
applyConnectionSpec(connectionSpec, socket, false);
assertArrayEquals(new String[] { "SSL_A", "SSL_C" }, socket.enabledCipherSuites);
}
use of okhttp3.ConnectionSpec in project okhttp by square.
the class CipherSuiteTest method applyIntersectionToProtocolVersion.
@Test
public void applyIntersectionToProtocolVersion() throws Exception {
FakeSslSocket socket = new FakeSslSocket();
socket.setEnabledProtocols(new String[] { "TLSv1", "TLSv1.1", "TLSv1.2" });
socket.setSupportedCipherSuites(new String[] { "TLS_A" });
socket.setEnabledCipherSuites(new String[] { "TLS_A" });
ConnectionSpec connectionSpec = new ConnectionSpec.Builder(true).tlsVersions(TlsVersion.TLS_1_1, TlsVersion.TLS_1_2, TlsVersion.TLS_1_3).cipherSuites("TLS_A").build();
applyConnectionSpec(connectionSpec, socket, false);
assertArrayEquals(new String[] { "TLSv1.1", "TLSv1.2" }, socket.enabledProtocols);
}
use of okhttp3.ConnectionSpec in project uCrop by Yalantis.
the class SampleApp method setUcropHttpClient.
private void setUcropHttpClient() {
ConnectionSpec cs = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS).allEnabledCipherSuites().allEnabledTlsVersions().build();
OkHttpClient client = new OkHttpClient.Builder().connectionSpecs(Collections.singletonList(cs)).build();
UCropHttpClientStore.INSTANCE.setClient(client);
}
Aggregations