summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/host-http/src/main
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2012-09-13 00:09:10 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2012-09-13 00:09:10 +0000
commitda0a1d98f35454e53eba96f0e14e5493c9512be5 (patch)
tree9b68621ed544b9f776f2c30fb5519974f0692a28 /sca-java-2.x/trunk/modules/host-http/src/main
parent6320f67c7cefc3e8c349676fe532098d172e2ef6 (diff)
Allow the fallback to default SSL in case of system default fails
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1384165 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/host-http/src/main')
-rw-r--r--sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java24
1 files changed, 10 insertions, 14 deletions
diff --git a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
index 35c07329bb..339d2f433e 100644
--- a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
+++ b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
@@ -19,25 +19,17 @@
package org.apache.tuscany.sca.host.http.client;
-import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.params.ConnManagerParams;
-import org.apache.http.conn.params.ConnPerRoute;
-import org.apache.http.conn.params.ConnPerRouteBean;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLInitializationException;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.impl.conn.SchemeRegistryFactory;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.protocol.HTTP;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
@@ -62,13 +54,17 @@ public class HttpClientFactory implements LifeCycleListener {
HttpConnectionParams.setSoTimeout(defaultParameters, 60000);
// See https://issues.apache.org/jira/browse/HTTPCLIENT-1138
- SchemeRegistry supportedSchemes = SchemeRegistryFactory.createSystemDefault();
- supportedSchemes.register(new Scheme(HttpHost.DEFAULT_SCHEME_NAME, 80, PlainSocketFactory.getSocketFactory()));
-
+ SchemeRegistry supportedSchemes = null;
+ try {
+ supportedSchemes = SchemeRegistryFactory.createSystemDefault();
+ } catch (SSLInitializationException e) {
+ // Fall back to the default as some systems don't have all properties configured correctly, such as the keyStorePassword
+ supportedSchemes = SchemeRegistryFactory.createDefault();
+ }
+
// FIXME: By pass host name verification
- SSLSocketFactory socketFactory = SSLSocketFactory.getSystemSocketFactory();
+ SSLSocketFactory socketFactory = (SSLSocketFactory)supportedSchemes.getScheme("https").getSchemeSocketFactory();
socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
- supportedSchemes.register(new Scheme("https", 443, socketFactory));
PoolingClientConnectionManager connectionManager =
new PoolingClientConnectionManager(supportedSchemes);