List of usage examples for com.squareup.okhttp TlsVersion TLS_1_2
TlsVersion TLS_1_2
To view the source code for com.squareup.okhttp TlsVersion TLS_1_2.
Click Source Link
From source file:com.granita.contacticloudsync.HttpClientTest.java
License:Open Source License
public void testTLSVersion() throws IOException { server.useHttps(new SSLSocketFactoryCompat(null), false); assertEquals("https", server.url("/").scheme()); httpClient.setConnectionSpecs(Collections.singletonList( new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS).tlsVersions(TlsVersion.TLS_1_2).build())); // FIXME//from www . jav a 2 s . c om /*server.enqueue(new MockResponse().setResponseCode(204)); Response response = httpClient.newCall(new Request.Builder() .get().url(server.url("/")) .build()).execute(); assertTrue(response.isSuccessful());*/ }
From source file:org.jclouds.docker.config.DockerOkHttpClientSupplier.java
License:Apache License
@Override public OkHttpClient get() { OkHttpClient client = new OkHttpClient(); ConnectionSpec tlsSpec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) .tlsVersions(TlsVersion.TLS_1_0, TlsVersion.TLS_1_1, TlsVersion.TLS_1_2).build(); ConnectionSpec cleartextSpec = new ConnectionSpec.Builder(ConnectionSpec.CLEARTEXT).build(); client.setConnectionSpecs(ImmutableList.of(tlsSpec, cleartextSpec)); // check if identity and credential are files, to set up sslContext if (new File(creds.get().identity).isFile() && new File(creds.get().credential).isFile()) { client.setSslSocketFactory(dockerSSLContextSupplier.get().getSocketFactory()); }/*from w w w.j a v a 2 s.co m*/ return client; }
From source file:org.jclouds.http.okhttp.OkHttpCommandExecutorServiceTest.java
License:Apache License
@Test public void testRestrictedSSLProtocols() throws Exception { MockWebServer server = mockWebServer(new MockResponse()); server.useHttps(sslContext.getSocketFactory(), false); ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS).tlsVersions(TlsVersion.TLS_1_2) .build();/*from w ww .ja v a2s.co m*/ PatchApi api = api(PatchApi.class, server.getUrl("/").toString(), new ConnectionSpecModule(spec)); try { api.patchNothing(""); assertEquals(server.getRequestCount(), 1); RecordedRequest request = server.takeRequest(); assertEquals(request.getSslProtocol(), "TLSv1.2"); } finally { closeQuietly(api); server.shutdown(); } }