From 6f81d8d0d3f4d1e3897927eb5801a8ca388c3e04 Mon Sep 17 00:00:00 2001 From: Dies Koper Date: Fri, 6 Jul 2012 12:40:48 +1000 Subject: [PATCH] improvement on previous change: decouple use of provider's SSLContext from trustAllCerts setting. This will allow providers to combine their SSLContext with the value of this option --- .../internal/JavaUrlHttpCommandExecutorService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java index 3143940ac8..c4e0136656 100644 --- a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java +++ b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java @@ -89,7 +89,7 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe private final HostnameVerifier verifier; private final Field methodField; @Inject(optional = true) - Supplier trustedSSLContextProvider; + Supplier sslContextSupplier; @Inject public JavaUrlHttpCommandExecutorService(HttpUtils utils, ContentMetadataCodec contentMetadataCodec, @@ -186,12 +186,12 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe HttpsURLConnection sslCon = (HttpsURLConnection) connection; if (utils.relaxHostname()) sslCon.setHostnameVerifier(verifier); - if (utils.trustAllCerts()) { - sslCon.setSSLSocketFactory(untrustedSSLContextProvider.get().getSocketFactory()); - } else if (trustedSSLContextProvider != null) { - // used for providers which use certs for authentication (like FGCP) + if (sslContextSupplier != null) { + // used for providers which e.g. use certs for authentication (like FGCP) // Provider provides SSLContext impl (which inits context with key manager) - sslCon.setSSLSocketFactory(trustedSSLContextProvider.get().getSocketFactory()); + sslCon.setSSLSocketFactory(sslContextSupplier.get().getSocketFactory()); + } else if (utils.trustAllCerts()) { + sslCon.setSSLSocketFactory(untrustedSSLContextProvider.get().getSocketFactory()); } } connection.setConnectTimeout(utils.getConnectionTimeout());