Source:
protected OkHttpClient.Builder setSSLSocketFactory( OkHttpClient.Builder builder, ServiceEndpoint serviceEndpoint) { if ((okHttpClientConfigurationProperties.getKeyStore() == null && okHttpClientConfigurationProperties.getTrustStore() == null) || serviceEndpoint instanceof PlainServiceEndpoint) { return builder; } try { KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore ks = KeyStore.getInstance(okHttpClientConfigurationProperties.getKeyStoreType()); ks.load( new FileInputStream(okHttpClientConfigurationProperties.getKeyStore()), okHttpClientConfigurationProperties.getKeyStorePassword().toCharArray()); keyManagerFactory.init( ks, okHttpClientConfigurationProperties.getKeyStorePassword().toCharArray()); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); KeyStore ts = KeyStore.getInstance(okHttpClientConfigurationProperties.getTrustStoreType()); ts.load( new FileInputStream(okHttpClientConfigurationProperties.getTrustStore()), okHttpClientConfigurationProperties.getTrustStorePassword().toCharArray()); trustManagerFactory.init(ts); SecureRandom secureRandom = SecureRandom.getInstance( okHttpClientConfigurationProperties.getSecureRandomInstanceType()); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init( keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), secureRandom); TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); checkState( trustManagers.length == 1, "Found multiple trust managers; don't know which one to use"); checkState( trustManagers[0] instanceof X509TrustManager, "Configured TrustManager is a %s, not an X509TrustManager; don't know how to configure it", trustManagers[0].getClass().getSimpleName()); builder.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]); } catch (Exception e) { log.error("Unable to set ssl socket factory for {}", serviceEndpoint.getBaseUrl(), e); throw new SystemException( format("Unable to set ssl socket factory for (%s)", serviceEndpoint.getBaseUrl()), e); } return builder; }

Target:
protected OkHttpClient.Builder setSSLSocketFactory( OkHttpClient.Builder builder, ServiceEndpoint serviceEndpoint) { if ((okHttpClientConfigurationProperties.getKeyStore() == null && okHttpClientConfigurationProperties.getTrustStore() == null) || serviceEndpoint.isUseDefaultSslSocketFactory()) { return builder; } try { KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore ks = KeyStore.getInstance(okHttpClientConfigurationProperties.getKeyStoreType()); ks.load( new FileInputStream(okHttpClientConfigurationProperties.getKeyStore()), okHttpClientConfigurationProperties.getKeyStorePassword().toCharArray()); keyManagerFactory.init( ks, okHttpClientConfigurationProperties.getKeyStorePassword().toCharArray()); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); KeyStore ts = KeyStore.getInstance(okHttpClientConfigurationProperties.getTrustStoreType()); ts.load( new FileInputStream(okHttpClientConfigurationProperties.getTrustStore()), okHttpClientConfigurationProperties.getTrustStorePassword().toCharArray()); trustManagerFactory.init(ts); SecureRandom secureRandom = SecureRandom.getInstance( okHttpClientConfigurationProperties.getSecureRandomInstanceType()); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init( keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), secureRandom); TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); checkState( trustManagers.length == 1, "Found multiple trust managers; don't know which one to use"); checkState( trustManagers[0] instanceof X509TrustManager, "Configured TrustManager is a %s, not an X509TrustManager; don't know how to configure it", trustManagers[0].getClass().getSimpleName()); builder.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]); } catch (Exception e) { log.error("Unable to set ssl socket factory for {}", serviceEndpoint.getBaseUrl(), e); throw new SystemException( format("Unable to set ssl socket factory for (%s)", serviceEndpoint.getBaseUrl()), e); } return builder; }