Repository: camel Updated Branches: refs/heads/master 9dd120a53 -> a6813a443
CAMEL-8707 Fixed the issue of camel-smpps doesn't work over proxy with thanks to Gururaja Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a6813a44 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a6813a44 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a6813a44 Branch: refs/heads/master Commit: a6813a4430fb4f19025898a64411d727b9e2c47b Parents: 9dd120a Author: Willem Jiang <willem.ji...@gmail.com> Authored: Tue Apr 28 14:23:24 2015 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Tue Apr 28 14:23:54 2015 +0800 ---------------------------------------------------------------------- .../component/smpp/SmppConnectionFactory.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/a6813a44/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java index 1f9d932..ff8a57b 100644 --- a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java +++ b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppConnectionFactory.java @@ -55,6 +55,7 @@ import java.io.OutputStream; import java.net.Socket; import javax.net.SocketFactory; +import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import org.apache.camel.RuntimeCamelException; @@ -84,15 +85,25 @@ public final class SmppConnectionFactory implements ConnectionFactory { try { Socket socket; SocketFactory socketFactory; - socketFactory = config.getUsingSSL() ? SSLSocketFactory.getDefault() : SocketFactory.getDefault(); + socketFactory = config.getUsingSSL() && config.getHttpProxyHost() == null ? SSLSocketFactory + .getDefault() : SocketFactory.getDefault(); if (config.getHttpProxyHost() != null) { + // setup the proxy tunnel socket = socketFactory.createSocket(config.getHttpProxyHost(), config.getHttpProxyPort()); connectProxy(host, port, socket); } else { socket = socketFactory.createSocket(host, port); } - return new SocketConnection(socket); + if (config.getUsingSSL() && config.getHttpProxyHost() != null) { + // Init the SSL socket which is based on the proxy socket + SSLSocketFactory sslSocketFactory = (SSLSocketFactory)SSLSocketFactory.getDefault(); + SSLSocket sslSocket = (SSLSocket)sslSocketFactory.createSocket(socket, host, port, true); + sslSocket.startHandshake(); + socket = sslSocket; + } + + return new SocketConnection(socket); } catch (Exception e) { throw new IOException(e.getMessage()); } @@ -167,4 +178,4 @@ public final class SmppConnectionFactory implements ConnectionFactory { } } } -} \ No newline at end of file +}