Example usage for com.squareup.okhttp TlsVersion TLS_1_1

List of usage examples for com.squareup.okhttp TlsVersion TLS_1_1

Introduction

In this page you can find the example usage for com.squareup.okhttp TlsVersion TLS_1_1.

Prototype

TlsVersion TLS_1_1

To view the source code for com.squareup.okhttp TlsVersion TLS_1_1.

Click Source Link

Usage

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 ww . j av  a  2 s  .  c  o  m*/
    return client;
}