Repository: jclouds-labs Updated Branches: refs/heads/master 3440a0b5e -> 8c340d1af
[JCLOUDS-1006] Fix DockerUntrustedSSLContextSupplier to allow tests runs against endpoints without TLS configured Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/d8e58a0f Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/d8e58a0f Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/d8e58a0f Branch: refs/heads/master Commit: d8e58a0fe2f982508ff113aa408f1049aae18a2c Parents: 3440a0b Author: Josef Cacek <[email protected]> Authored: Mon Sep 28 11:08:59 2015 +0200 Committer: Josef Cacek <[email protected]> Committed: Mon Sep 28 11:19:02 2015 +0200 ---------------------------------------------------------------------- .../suppliers/DockerUntrustedSSLContextSupplier.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d8e58a0f/docker/src/main/java/org/jclouds/docker/suppliers/DockerUntrustedSSLContextSupplier.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/suppliers/DockerUntrustedSSLContextSupplier.java b/docker/src/main/java/org/jclouds/docker/suppliers/DockerUntrustedSSLContextSupplier.java index d0c9077..42efa13 100644 --- a/docker/src/main/java/org/jclouds/docker/suppliers/DockerUntrustedSSLContextSupplier.java +++ b/docker/src/main/java/org/jclouds/docker/suppliers/DockerUntrustedSSLContextSupplier.java @@ -24,10 +24,11 @@ import org.jclouds.location.Provider; import javax.inject.Inject; import javax.inject.Singleton; import javax.net.ssl.SSLContext; + +import java.io.File; import java.io.IOException; import java.security.GeneralSecurityException; -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Throwables.propagate; @Singleton @@ -44,10 +45,13 @@ public class DockerUntrustedSSLContextSupplier implements Supplier<SSLContext> { @Override public SSLContext get() { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); + Credentials currentCreds = creds.get(); try { SSLContextBuilder builder = new SSLContextBuilder(); - builder.clientKeyAndCertificate(currentCreds.credential, currentCreds.identity); + // check if identity and credential are files, to set up sslContext + if (currentCreds!=null && new File(currentCreds.identity).isFile() && new File(currentCreds.credential).isFile()) { + builder.clientKeyAndCertificate(currentCreds.credential, currentCreds.identity); + } builder.trustManager(insecureTrustManager); return builder.build(); } catch (GeneralSecurityException e) {
