diff options
author | slewis | 2008-09-16 17:14:46 +0000 |
---|---|---|
committer | slewis | 2008-09-16 17:14:46 +0000 |
commit | 0c49d8e0276795e885389440ac4cc2b8eb00b06c (patch) | |
tree | 7f89f7cb11ed9a7e6d979022363a0b6037829d39 | |
parent | 385cecff81a901bfc1738b0d3fe5afe19789509f (diff) | |
download | org.eclipse.ecf-0c49d8e0276795e885389440ac4cc2b8eb00b06c.tar.gz org.eclipse.ecf-0c49d8e0276795e885389440ac4cc2b8eb00b06c.tar.xz org.eclipse.ecf-0c49d8e0276795e885389440ac4cc2b8eb00b06c.zip |
Changes to use SSLSocketFactory.getDefault() to get default socket factory. This applied to both ECFSSLSocketFactory and HttpClientSslProtocolSocketFactory. See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=224196#c71
-rw-r--r-- | framework/bundles/org.eclipse.ecf.ssl/src/org/eclipse/ecf/internal/ssl/ECFSSLSocketFactory.java | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/framework/bundles/org.eclipse.ecf.ssl/src/org/eclipse/ecf/internal/ssl/ECFSSLSocketFactory.java b/framework/bundles/org.eclipse.ecf.ssl/src/org/eclipse/ecf/internal/ssl/ECFSSLSocketFactory.java index e9208abb6..541ec1eab 100644 --- a/framework/bundles/org.eclipse.ecf.ssl/src/org/eclipse/ecf/internal/ssl/ECFSSLSocketFactory.java +++ b/framework/bundles/org.eclipse.ecf.ssl/src/org/eclipse/ecf/internal/ssl/ECFSSLSocketFactory.java @@ -17,20 +17,41 @@ import javax.net.ssl.*; public class ECFSSLSocketFactory extends SSLSocketFactory { + public static final String DEFAULT_SSL_PROTOCOL = "https.protocols"; //$NON-NLS-1$ + private SSLContext sslContext = null; + private String defaultProtocolNames = System.getProperty(DEFAULT_SSL_PROTOCOL); + private SSLSocketFactory getSSLSocketFactory() throws IOException { if (null == sslContext) { try { - sslContext = SSLContext.getInstance("SSL"); //$NON-NLS-1$ - sslContext.init(null, new TrustManager[] {new ECFTrustManager()}, new SecureRandom()); + sslContext = getSSLContext(defaultProtocolNames); } catch (Exception e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; } } - return sslContext.getSocketFactory(); + return (sslContext == null) ? (SSLSocketFactory) SSLSocketFactory.getDefault() : sslContext.getSocketFactory(); + } + + public SSLContext getSSLContext(String protocols) { + SSLContext rtvContext = null; + + if (protocols != null) { + String protocolNames[] = protocols.split(","); //$NON-NLS-1$ + for (int i = 0; i < protocolNames.length; i++) { + try { + rtvContext = SSLContext.getInstance(protocolNames[i]); + rtvContext.init(null, new TrustManager[] {new ECFTrustManager()}, new SecureRandom()); + break; + } catch (Exception e) { + // just continue to look for SSLContexts with the next protocolName + } + } + } + return rtvContext; } public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException { |